:root {
  --bg: #0b1220; --panel: #111a2e; --panel2: #16213a; --line: #22304f; --text: #e6ecf7; --muted: #8b9bb8;
  --green: #22c55e; --green-d: #15803d; --red: #ef4444; --amber: #f59e0b; --blue: #60a5fa; --teal: #2dd4bf;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, sans-serif; }
.hidden { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select { font: inherit; color: var(--text); background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid #2dd4bf55; border-color: var(--teal); }
.muted { color: var(--muted); }
.err { color: var(--red); min-height: 1.2em; }
.mono { font-family: var(--mono); }
.up { color: var(--green); } .down { color: var(--red); }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #3a4c75; }
.btn.primary { background: var(--teal); color: #052e2b; border-color: var(--teal); }
.btn.icon { padding: 9px 12px; }
.btn:disabled { opacity: .6; cursor: wait; }

.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; width: min(380px, 100%); display: grid; gap: 12px; }
.brand { font-weight: 800; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand.big { font-size: 24px; }
.logo { color: var(--teal); }

.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 12px; align-items: center; padding: 12px 20px; background: #0b1220ee; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.lookup { flex: 1; max-width: 420px; margin-left: auto; }
.lookup input { padding: 8px 12px; }
.top-actions { display: flex; gap: 8px; }

.market { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; padding: 16px 20px 6px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat .s { color: var(--muted); font-size: 12.5px; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.on { background: #22c55e22; color: var(--green); } .pill.off { background: #ef444422; color: var(--red); } .pill.neutral { background: #f59e0b22; color: var(--amber); }
.progress { height: 6px; background: var(--panel2); border-radius: 9px; overflow: hidden; margin-top: 8px; }
.progress > div { height: 100%; background: var(--teal); transition: width .4s; }

.tabs { display: flex; gap: 4px; padding: 10px 20px 0; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; border-radius: 10px 10px 0 0; color: var(--muted); font-weight: 600; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--teal); }
main { padding: 14px 20px 30px; min-height: 50vh; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px; cursor: pointer; transition: border-color .15s, transform .15s; }
.card:hover { border-color: #3a4c75; transform: translateY(-1px); }
.card-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.code { font-weight: 800; font-size: 18px; }
.name { color: var(--muted); font-size: 13px; }
.score { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-family: var(--mono); flex: none; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-right: 6px; }
.tag.buy { background: #22c55e22; color: var(--green); } .tag.watch { background: #60a5fa22; color: var(--blue); } .tag.avoid { background: #ef444422; color: var(--red); } .tag.setup { background: var(--panel2); color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 8px; }
.levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 10px; }
.lv { background: var(--panel2); border-radius: 9px; padding: 6px 8px; }
.lv .k { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.lv .v { font-family: var(--mono); font-weight: 600; font-size: 13.5px; }
.lv.entry .v { color: var(--blue); } .lv.stop .v { color: var(--red); } .lv.tgt .v { color: var(--green); }
.ai-line { margin-top: 10px; font-size: 13.5px; color: #c8d3ea; border-left: 3px solid var(--teal); padding-left: 9px; }
.why { font-size: 13px; color: var(--muted); margin-top: 8px; }
.empty { color: var(--muted); padding: 30px; text-align: center; border: 1px dashed var(--line); border-radius: 16px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px; border-bottom: 1px solid var(--line); position: sticky; top: 58px; background: var(--bg); cursor: pointer; }
.tbl td { padding: 8px; border-bottom: 1px solid #1a2541; }
.tbl tr:hover td { background: #121c33; cursor: pointer; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 160px; padding: 8px 10px; }
.tbl-wrap { overflow-x: auto; }

.drawer { position: fixed; inset: 0; z-index: 20; }
.drawer-bg { position: absolute; inset: 0; background: #000a; }
.drawer-panel { position: absolute; right: 0; top: 0; bottom: 0; width: min(860px, 100%); background: var(--bg); border-left: 1px solid var(--line); overflow-y: auto; padding: 20px 22px 40px; }
.close { position: sticky; top: 0; float: right; background: var(--panel2); border: 1px solid var(--line); border-radius: 50%; width: 36px; height: 36px; z-index: 2; }
.d-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.d-head .code { font-size: 26px; }
.price { font-family: var(--mono); font-size: 22px; font-weight: 600; }
#chart { height: 360px; margin: 14px 0; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.section { margin-top: 20px; }
.section h3 { margin: 0 0 10px; font-size: 15px; letter-spacing: .02em; }
.ai-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.ai-box p { margin: 6px 0 10px; }
.ai-box .lbl { color: var(--teal); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.conv { letter-spacing: 2px; color: var(--amber); }
.sizing { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; align-items: end; }
.news a { color: var(--blue); text-decoration: none; } .news li { margin-bottom: 4px; font-size: 13.5px; }

.chat { display: grid; gap: 10px; max-width: 860px; }
.msg { padding: 12px 14px; border-radius: 14px; max-width: 92%; }
.msg.user { background: #2dd4bf1f; justify-self: end; }
.msg.assistant { background: var(--panel); border: 1px solid var(--line); }
.msg p { margin: 0 0 8px; } .msg ul { margin: 4px 0 8px 18px; padding: 0; }
.chat-form { display: flex; gap: 8px; margin-top: 12px; max-width: 860px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { background: var(--panel2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; }

.settings { display: grid; gap: 14px; max-width: 560px; }
.settings label { display: grid; gap: 6px; font-size: 13.5px; color: var(--muted); }
.foot { color: #6b7a96; font-size: 12px; padding: 20px; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 12px; z-index: 30; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--muted); border-top-color: transparent; border-radius: 50%; animation: s 0.8s linear infinite; vertical-align: -2px; }
@keyframes s { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .top { flex-wrap: wrap; padding: 10px 16px; }
  .lookup { order: 3; max-width: none; flex-basis: 100%; }
  .market, .tabs, main { padding-left: 16px; padding-right: 16px; }
  .market { display: flex; overflow-x: auto; scrollbar-width: none; }
  .market .stat { min-width: 160px; flex: none; }
  .grid { grid-template-columns: 1fr; }
  .drawer-panel { padding: 16px; }
  #chart { height: 280px; }
}
