:root {
  --bg: #0B0F14; --surface: #121821; --surface2: #0F141B; --border: #1E2733; --border2: #2A3646;
  --text: #E6EDF3; --muted: #9AA7B4; --dim: #6B7785;
  --green: #34D399; --green-bg: #0F3B2A; --green-ink: #052A1B;
  --red: #F87171; --red-bg: #4A1D1D; --gold: #F5C66B; --gold-bg: #3A2E12; --blue: #4C9EFF; --blue-bg: #17324F;
  --radius: 14px;
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.up { color: var(--green); } .down { color: var(--red); }
.hidden { display: none !important; }

/* ---------- login ---------- */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 18px; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: var(--blue-bg); color: #CFE3FF; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }
label { font-size: 13px; color: var(--muted); }
input[type=password], input[type=number], input[type=text], textarea {
  width: 100%; min-height: 44px; background: var(--bg); border: 1px solid var(--border2); border-radius: 10px; padding: 10px 12px; outline: none;
}
input:focus, textarea:focus { border-color: var(--blue); }

/* ---------- buttons ---------- */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--border2); background: transparent; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; }
.btn:hover { border-color: #3A4757; background: #161E29; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #04162E; }
.btn.good { background: var(--green); border-color: var(--green); color: var(--green-ink); }
.btn.danger { background: var(--red-bg); border-color: #7A2E2E; color: #FFD2D2; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.link { border: 0; color: var(--blue); padding: 0 8px; }
.seg { display: inline-flex; border: 1px solid var(--border2); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 36px; padding: 0 12px; background: transparent; border: 0; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed=true] { background: var(--text); color: var(--bg); }

/* ---------- header ---------- */
header.top { position: sticky; top: 0; z-index: 10; background: rgba(11,15,20,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-inner { max-width: 1400px; margin: 0 auto; padding: 12px 24px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.pill { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; letter-spacing: .03em; white-space: nowrap; }
.pill.paper { background: var(--gold-bg); color: var(--gold); }
.pill.mode { background: var(--blue-bg); color: #CFE3FF; }
.pill.paused { background: var(--red-bg); color: #FFD2D2; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 0 rgba(52,211,153,.6); animation: pulse 2s infinite; }
.dot.off { background: var(--red); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,.5);} 70% { box-shadow: 0 0 0 8px rgba(52,211,153,0);} 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0);} }
nav.tabs { max-width: 1400px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; overflow-x: auto; }
nav.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 600; white-space: nowrap; min-height: 44px; }
nav.tabs button[aria-current=page] { color: var(--text); border-bottom-color: var(--blue); }

/* ---------- layout ---------- */
main { max-width: 1400px; margin: 0 auto; padding: 20px 24px 60px; display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { margin: 0 0 12px; font-size: 17px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card h2 .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.kpi .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.kpi .v { font-family: var(--mono); font-size: 22px; font-weight: 600; }
.kpi .s { font-size: 12px; color: var(--muted); }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 18px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 1050px) { .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 600px) { .top-inner, main, nav.tabs { padding-left: 16px; padding-right: 16px; } .card { padding: 14px; } .grid-2 { grid-template-columns: 1fr; } }

/* ---------- chart ---------- */
.chart-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sym { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.sym .name { font-size: 20px; font-weight: 800; }
.sym .price { font-family: var(--mono); font-size: 20px; }
.sym .chg { font-family: var(--mono); font-size: 14px; }
#chart { height: 440px; width: 100%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 14px; height: 0; border-top: 2px dashed currentColor; margin-right: 6px; vertical-align: middle; }
.legend .l-entry { color: var(--blue); } .legend .l-stop { color: var(--red); } .legend .l-target { color: var(--green); }
.page-sym { font-size: 12px; color: var(--gold); }

/* ---------- suggestions ---------- */
.sugg { border: 1px solid var(--border2); border-radius: 12px; padding: 14px; background: var(--surface2); display: flex; flex-direction: column; gap: 10px; }
.sugg + .sugg { margin-top: 12px; }
.sugg.good { border-color: #1F5A43; }
.sugg-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.tag { font-family: var(--mono); font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.tag.buy { background: var(--green-bg); color: #5EEAB0; } .tag.sell { background: var(--red-bg); color: #FCA5A5; } .tag.wait { background: #1C2633; color: #C3CDD7; }
.tag.good { background: var(--green-bg); color: #5EEAB0; } .tag.skip { background: #2A2015; color: var(--gold); }
.odds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.odds div { background: var(--bg); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.odds .k { font-size: 11px; color: var(--muted); }
.odds .v { font-family: var(--mono); font-weight: 700; font-size: 16px; }
.levels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; font-family: var(--mono); font-size: 13px; }
.levels .k { font-family: var(--font); color: var(--muted); font-size: 11px; display: block; }
.reason { font-size: 13px; color: #C3CDD7; line-height: 1.45; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.status-line { font-size: 13px; font-weight: 600; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }
.mini-list > div { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 14px; align-items: center; }
.mini-list > div:first-child { border-top: 0; }

/* ---------- trades ---------- */
.trade { border: 1px solid var(--border2); border-radius: 12px; padding: 12px 14px; background: var(--surface2); display: flex; flex-direction: column; gap: 8px; }
.trade + .trade { margin-top: 10px; }
.bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--blue); border-radius: 99px; }

/* ---------- chat ---------- */
.chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto; padding: 4px 2px 10px; }
.msg { max-width: 85%; padding: 10px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #1D4F86; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: #161E29; border-bottom-left-radius: 4px; }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; border-radius: 99px; padding: 0 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { font-size: 12px; padding: 6px 10px; border-radius: 99px; border: 1px solid var(--border2); background: transparent; cursor: pointer; color: #C3CDD7; min-height: 32px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
td.lesson { color: #C3CDD7; font-size: 13px; max-width: 380px; }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.help { font-size: 12px; color: var(--dim); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: #C3CDD7; }

/* ---------- modal + toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-box { background: var(--surface); border: 1px solid var(--border2); border-radius: 16px; padding: 22px; max-width: 520px; width: 100%; display: flex; flex-direction: column; gap: 14px; }
.modal-box p { margin: 0; line-height: 1.6; white-space: pre-wrap; color: #DCE4EC; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
.toast { background: #17202B; border: 1px solid var(--border2); border-radius: 12px; padding: 12px 14px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 380px; }
.toast.ok { border-color: #1F5A43; } .toast.err { border-color: #7A2E2E; }

/* ---------- compact (browser extension side panel) ---------- */
body.compact header.top .top-inner { padding: 10px 12px; }
body.compact nav.tabs { padding: 0 8px; }
body.compact nav.tabs button { padding: 8px 10px; font-size: 13px; }
body.compact main { padding: 12px; gap: 12px; }
body.compact .grid-main { grid-template-columns: 1fr; gap: 12px; }
body.compact .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
body.compact .kpi { padding: 10px 12px; } body.compact .kpi .v { font-size: 17px; }
body.compact .kpi.optional { display: none; }
body.compact #chart { height: 260px; }
body.compact .card { padding: 12px; }
body.compact .hide-compact { display: none !important; }
