:root {
  color-scheme: dark;
  --bg: #090a0d;
  --card: #111319;
  --elev: #181b22;
  --border: #272b35;
  --text: #f2f3f5;
  --muted: #8b909c;
  --violet: #9b7bff;
  --violet-2: #b29aff;
  --green: #35d07f;
  --red: #ff5c6c;
  --amber: #f5b942;
  --blue: #55a7ff;
}

* { box-sizing: border-box; }
html { min-width: 0; background: var(--bg); }
body { margin: 0; min-width: 0; overflow-x: hidden; background: var(--bg); color: var(--text); font: 14px Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }

.shell { min-height: 100vh; max-width: 100%; overflow-x: clip; }
.app { width: 100%; max-width: 620px; min-height: 100vh; margin: 0 auto; padding: 18px 16px 98px; }
.screen { display: none; }
.screen.active { display: block; }
.desktop-nav { display: none; }
.top, .page-header, .row, .section-heading, .toggle-row { display: flex; align-items: center; }
.top, .page-header, .section-heading, .between, .toggle-row { justify-content: space-between; }
.home-top { margin: 4px 0 18px; }
.page-header { gap: 16px; margin: 4px 0 18px; }
.page-header h1, .section-heading h1 { margin-top: 3px; font-size: 23px; line-height: 1.1; }
.row { gap: 10px; }
.align-start { align-items: flex-start; }

.brand-wrap { display: flex; align-items: center; gap: 11px; min-width: 0; }
.mark { display: grid; flex: 0 0 auto; width: 42px; height: 42px; place-items: center; overflow: hidden; border: 1px solid #594a88; border-radius: 12px; background: linear-gradient(145deg, #1b1729, #0d0f14); box-shadow: 0 0 24px #9b7bff22; }
.mark img { display: block; width: 34px; height: 34px; object-fit: contain; filter: drop-shadow(0 0 8px #9b7bff55); }
.brand { display: block; overflow: hidden; font-size: 24px; font-weight: 800; letter-spacing: 7px; white-space: nowrap; }
.brand > span { color: var(--violet-2); text-shadow: 0 0 16px #9b7bff66; }
.brand-wrap small { display: block; margin-top: 2px; overflow: hidden; color: var(--muted); font-size: 8px; letter-spacing: 2.3px; text-overflow: ellipsis; white-space: nowrap; }
.badges { display: flex; align-items: center; gap: 7px; }
.prototype-pill, .state-pill, .mini-pill { display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; font-size: 9px; font-weight: 850; letter-spacing: .7px; }
.prototype-pill { padding: 5px 8px; border: 1px solid #4a3b78; background: #211b38; color: #c8b9ff; }
.state-pill, .mini-pill { padding: 6px 9px; border: 1px solid var(--border); background: var(--elev); color: var(--muted); }
.state-pill.running { border-color: #245a3e; background: #173226; color: #b8f3d4; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }
.dot.paused { background: var(--muted); box-shadow: none; }

.card, .metric { border: 1px solid var(--border); background: var(--card); border-radius: 17px; }
.card { margin-bottom: 12px; padding: 15px; }
.eyebrow, .label, .field-label { color: var(--muted); font-size: 10px; letter-spacing: .8px; text-transform: uppercase; }
.price { display: block; margin: 5px 0; font-size: clamp(27px, 8vw, 32px); font-weight: 850; }
.change { color: var(--muted); font-size: 12px; font-weight: 750; }
.up, .positive { color: var(--green) !important; }
.down, .negative { color: var(--red) !important; }
.source { display: grid; gap: 3px; min-width: 0; max-width: 46%; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); font-size: 9px; text-align: right; }
.source b { overflow-wrap: anywhere; color: #c8b9ff; }
.source small { overflow-wrap: anywhere; color: var(--muted); }
.sub { color: var(--muted); font-size: 11px; line-height: 1.45; }
.demo-note, .safety-note { border: 1px solid #34304a; background: #151421; color: #aeb1bd; }
.demo-note { margin-top: 11px; padding: 8px 10px; border-radius: 9px; font-size: 10px; line-height: 1.4; }

.chart { height: 190px; margin-top: 12px; overflow: hidden; border-radius: 13px; background: linear-gradient(180deg, #12151d, #0c0e13); }
.chart canvas, .wallet-chart canvas { display: block; width: 100%; height: 100%; }
.tf, .tabs, .filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tf::-webkit-scrollbar, .tabs::-webkit-scrollbar, .filters::-webkit-scrollbar { display: none; }
.tf { padding: 8px 0 2px; }
.tf button, .chip, .tabs button { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--elev); color: var(--muted); white-space: nowrap; }
.tf button.active, .chip.active, .tabs button.active { border-color: #5c4a92; background: #251e3e; color: #d4caff; }
.temperature-block { margin-top: 13px; }
.temperature { color: var(--violet-2); font-size: 12px; }
.temperature-track { height: 9px; margin-top: 7px; overflow: hidden; border: 1px solid #303440; border-radius: 999px; background: #20232b; }
.temperature-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--violet), var(--amber)); transition: width .45s ease; }
.note { margin-top: 8px; color: var(--muted); font-size: 10px; line-height: 1.45; }

.section-heading { gap: 12px; margin: 18px 2px 10px; }
.tabs { padding: 0 0 8px; }
.tabs button { flex: 1 0 auto; }
.tabs button span { display: inline-grid; min-width: 18px; height: 18px; margin-left: 3px; place-items: center; border-radius: 99px; background: #0f1116; font-size: 9px; }
.operations-card { padding: 4px 15px; }
.empty-state { padding: 30px 10px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--text); }
.operation-head { display: none; }
.operation-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.operation-item:last-child { border-bottom: 0; }
.operation-summary { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; align-items: start; list-style: none; cursor: pointer; }
.operation-summary::-webkit-details-marker { display: none; }
.operation-primary { display: flex; align-items: center; gap: 7px; min-width: 0; }
.status { padding: 4px 6px; border-radius: 6px; background: #222630; color: #c9ccd3; font-size: 9px; font-weight: 900; letter-spacing: .5px; }
.status.open { background: #173226; color: #b8f3d4; }
.status.wait { background: #352a16; color: #ffe0a2; }
.side { font-size: 11px; font-weight: 900; }
.operation-pnl { font-size: 16px; font-weight: 900; text-align: right; }
.operation-meta { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; font-size: 11px; }
.operation-meta span:nth-child(odd) { color: var(--muted); }
.operation-meta span:nth-child(even) { text-align: right; }
.operation-body { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.detail-grid span { color: var(--muted); font-size: 10px; }
.detail-grid strong { display: block; margin-top: 3px; color: var(--text); font-size: 12px; overflow-wrap: anywhere; }
.detail-title { margin: 13px 0 7px; color: #c8b9ff; font-size: 9px; font-weight: 850; letter-spacing: .8px; text-transform: uppercase; }
.close-trade { width: 100%; margin-top: 13px; padding: 10px; border: 1px solid #5c3540; border-radius: 10px; background: #28161b; color: #ffb3bc; font-weight: 800; }
.quick-actions .action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.long, .short, .save, .ghost { min-height: 39px; border-radius: 10px; font-weight: 850; }
.long { border: 1px solid var(--green); background: var(--green); color: #062116; }
.short { border: 1px solid var(--red); background: var(--red); color: #2b080d; }
.ghost { border: 1px solid var(--border); background: var(--elev); color: var(--text); }
.logout { min-height: auto; padding: 6px 8px; color: var(--muted); font-size: 10px; }

.wallet-hero { padding: 20px 15px; text-align: center; }
.wallet-total { display: block; margin: 5px 0; font-size: clamp(30px, 9vw, 38px); font-weight: 900; }
.wallet-chart { height: 185px; margin-top: 15px; }
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.metric { min-width: 0; padding: 13px; }
.metric strong { display: block; margin-top: 5px; font-size: 15px; overflow-wrap: anywhere; }

.settings-layout { display: grid; gap: 12px; }
.settings-layout .card { margin: 0; }
.robot-toggle-row { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.robot-toggle-row strong { font-size: 16px; }
.full-field { margin-top: 15px; }
.field-label { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; font-weight: 700; }
.field-label small { margin-left: auto; color: var(--muted); font-size: 9px; font-weight: 500; text-transform: none; }
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
.settings-primary .settings-grid { margin-top: 13px; }
.setting { min-width: 0; }
.setting input, .setting select { width: 100%; min-width: 0; padding: 11px; outline: 0; border: 1px solid var(--border); border-radius: 11px; background: #0d0f14; color: var(--text); }
.setting input:focus, .setting select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px #9b7bff18; }
.segment { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.segment label { cursor: pointer; }
.segment input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segment span { display: block; padding: 10px 5px; border: 1px solid var(--border); border-radius: 10px; background: var(--elev); color: var(--muted); text-align: center; }
.segment input:checked + span { border-color: var(--violet); background: #251e3e; color: #e1d9ff; }
.switch { position: relative; display: block; flex: 0 0 auto; width: 48px; height: 27px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.slider { position: absolute; inset: 0; border: 1px solid #363b46; border-radius: 99px; background: #282c35; transition: .2s; }
.slider::before { position: absolute; top: 2px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #d4d6dc; content: ""; transition: .2s; }
.switch input:checked + .slider { border-color: #765fba; background: #3d3262; }
.switch input:checked + .slider::before { transform: translateX(20px); background: #cdbfff; }
.switch input:focus-visible + .slider { outline: 2px solid var(--violet); outline-offset: 2px; }
.switch.compact { width: 42px; height: 24px; }
.switch.compact .slider::before { width: 17px; height: 17px; }
.switch.compact input:checked + .slider::before { transform: translateX(18px); }
.toggle-grid { display: grid; gap: 8px; margin-top: 15px; }
.toggle-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px; border: 1px solid var(--border); border-radius: 11px; background: #0d0f14; }
.toggle-option strong, .toggle-option small { display: block; }
.toggle-option small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.safety-note { display: grid; gap: 3px; margin-top: 14px; padding: 11px; border-radius: 11px; font-size: 11px; line-height: 1.4; }
.safety-note strong { color: #d5ccff; }
.settings-actions { display: grid; gap: 8px; margin-top: 16px; }
.save { border: 0; background: var(--violet); color: #0b0811; }
.danger { border-color: #59303a; color: #ffb8c0; }
.help { position: relative; display: inline-grid; flex: 0 0 auto; width: 19px; height: 19px; padding: 0; place-items: center; border: 1px solid #594a88; border-radius: 50%; background: #211b38; color: #c8b9ff; font-size: 10px; }
.help::after { position: absolute; z-index: 30; right: 0; bottom: calc(100% + 8px); width: min(250px, calc(100vw - 32px)); padding: 10px 11px; border: 1px solid #5c4a92; border-radius: 10px; background: #211d2c; box-shadow: 0 12px 32px #000b; color: var(--text); content: attr(data-tooltip); font-size: 11px; font-weight: 500; letter-spacing: 0; line-height: 1.4; text-align: left; text-transform: none; opacity: 0; pointer-events: none; transform: translateY(4px); transition: .15s; }
.help:hover::after, .help:focus-visible::after, .help.open::after { opacity: 1; transform: translateY(0); }

.filters { padding: 0 0 10px; }
.log-card { padding: 0 15px; }
.log-header, .log-row { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 10px; }
.log-header { padding: 11px 0; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 9px; letter-spacing: .6px; text-transform: uppercase; }
.log-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.log-row:last-child { border-bottom: 0; }
.log-time { color: var(--muted); font-size: 11px; }
.log-category { display: block; margin-bottom: 3px; color: var(--blue); font-size: 10px; font-weight: 850; }
.log-category.operacoes { color: var(--green); }
.log-category.alertas { color: var(--amber); }
.log-message { color: #c7cad1; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }

.mobile-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 7px 8px calc(7px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: #0e1015f7; backdrop-filter: blur(14px); }
.mobile-nav button { min-width: 0; padding: 7px 2px; border: 0; background: transparent; color: var(--muted); font-size: 10px; font-weight: 750; }
.mobile-nav button span { display: block; margin-bottom: 2px; font-size: 17px; line-height: 1; }
.mobile-nav button.active { color: var(--violet-2); }
#toast { position: fixed; z-index: 50; right: 14px; bottom: 84px; left: 14px; padding: 12px 14px; border: 1px solid #5c4a92; border-radius: 11px; background: #211d2c; box-shadow: 0 15px 40px #000b; color: var(--text); font-size: 12px; font-weight: 750; opacity: 0; pointer-events: none; transform: translateY(20px); transition: .2s; }
#toast.show { opacity: 1; transform: translateY(0); }

/* Login preserva a autenticação existente, agora com a identidade LYRA. */
.login-page { display: grid; min-height: 100vh; padding: 20px; place-items: center; }
.login-shell { width: min(430px, 100%); }
.login-card { padding: 30px; border: 1px solid var(--border); border-radius: 20px; background: var(--card); box-shadow: 0 24px 80px #0009; }
.login-brand { margin-bottom: 22px; }
.login-card h1 { margin: 7px 0; font-size: clamp(2.2rem, 10vw, 3.4rem); }
.subtitle { color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 14px; margin-top: 26px; }
.login-form label { color: var(--muted); font-size: 11px; font-weight: 700; }
.login-form input { width: 100%; margin-top: 6px; padding: 12px; border: 1px solid var(--border); border-radius: 11px; outline: 0; background: #0d0f14; color: var(--text); }
.login-form input:focus { border-color: var(--violet); }
.login-form button { min-height: 43px; border: 0; border-radius: 11px; background: var(--violet); color: #0b0811; font-weight: 900; }
.login-message { min-height: 1.4em; margin-top: 12px; color: var(--red); font-size: 11px; }
.simulation-note { margin-top: 18px; color: var(--muted); font-size: 10px; text-align: center; }

@media (max-width: 420px) {
  .app { padding-right: 12px; padding-left: 12px; }
  .brand { font-size: 21px; letter-spacing: 5px; }
  .brand-wrap small { max-width: 128px; font-size: 6.5px; letter-spacing: 1px; }
  .prototype-pill { padding: 5px 6px; font-size: 8px; }
  .logout { display: none; }
  .detail-grid, .metrics { grid-template-columns: 1fr; }
  .price-card .source { max-width: 42%; }
}

@media (min-width: 768px) {
  .app { max-width: 1120px; padding: 25px 28px 102px; }
  .chart { height: 260px; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(340px, .88fr); gap: 14px; align-items: start; }
  .section-heading { margin-top: 0; }
  .wallet-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr); gap: 12px; align-items: start; }
  .metrics { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toggle-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #toast { right: 24px; bottom: 96px; left: auto; width: 360px; }
}

@media (min-width: 1200px) {
  .shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
  .desktop-nav { position: sticky; top: 0; display: flex; flex-direction: column; width: 240px; height: 100vh; padding: 26px 18px; border-right: 1px solid var(--border); background: #0c0e12; }
  .desktop-nav .brand-wrap { padding: 0 7px 24px; }
  .desktop-nav .brand { font-size: 21px; }
  .desktop-nav .brand-wrap small { max-width: 145px; letter-spacing: 1.2px; }
  .nav-list { display: grid; gap: 6px; }
  .nav-list button { display: flex; align-items: center; gap: 11px; padding: 12px; border: 1px solid transparent; border-radius: 11px; background: transparent; color: var(--muted); font-weight: 750; text-align: left; }
  .nav-list button span { width: 23px; color: var(--violet-2); font-size: 18px; text-align: center; }
  .nav-list button.active { border-color: #3e345f; background: #201b31; color: var(--text); }
  .sidebar-foot { display: grid; gap: 10px; margin-top: auto; padding: 14px 7px 0; border-top: 1px solid var(--border); }
  .sidebar-foot .prototype-pill { justify-self: start; }
  .sidebar-foot small { color: var(--muted); line-height: 1.45; }
  .sidebar-foot .logout { display: block; }
  .app { max-width: 1480px; padding: 30px 34px 48px; }
  .mobile-nav { display: none; }
  .mobile-brand { display: none; }
  .home-top { min-height: 42px; justify-content: flex-end; }
  .home-grid { grid-template-columns: minmax(0, 1.18fr) minmax(340px, .82fr); gap: 18px; }
  .chart { height: 360px; }
  .card { padding: 18px; }
  .operations-card { padding: 0 18px; }
  .operation-head { display: grid; grid-template-columns: 1.1fr .65fr .8fr .9fr .9fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 9px; letter-spacing: .5px; text-transform: uppercase; }
  .operation-summary { grid-template-columns: 1.1fr .65fr .8fr .9fr .9fr; align-items: center; }
  .operation-primary { grid-column: auto; }
  .operation-pnl { grid-column: 5; grid-row: 1; font-size: 13px; }
  .operation-meta { display: contents; }
  .operation-meta span { text-align: left !important; }
  .operation-meta span:nth-child(odd) { display: none; }
  .operation-meta span:nth-child(2) { grid-column: 2; grid-row: 1; }
  .operation-meta span:nth-child(4) { grid-column: 3; grid-row: 1; }
  .operation-meta span:nth-child(6) { grid-column: 4; grid-row: 1; }
  .operation-meta span:nth-child(8) { display: none; }
  .settings-layout { grid-template-columns: minmax(260px, .36fr) minmax(0, .64fr); align-items: start; }
  .settings-primary { position: sticky; top: 30px; }
  .settings-layout, .settings-primary, .settings-fields { min-width: 0; }
  .settings-fields .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wallet-layout { grid-template-columns: minmax(0, 1.45fr) minmax(320px, .55fr); gap: 16px; }
  .wallet-chart { height: 300px; }
  #toast { bottom: 28px; }
}

@media (min-width: 1800px) {
  .app { max-width: 1680px; padding-right: 54px; padding-left: 54px; }
  .home-grid { grid-template-columns: minmax(720px, 1.45fr) minmax(520px, .75fr); }
  .chart { height: 420px; }
}
