/* ============ MI — Master Intelligence · design tokens ============ */
:root {
  --bg: #080c14;
  --bg2: #0f1520;
  --card: #141c2c;
  --card2: #1a2438;
  --line: #23324a;
  --line2: #32456a;
  --text: #edf2fc;
  --text2: #9fb1c9;
  --muted: #64768f;
  --green: #10b981;
  --red: #ef4444;
  --blue: #3b82f6;
  --gold: #f59e0b;
  --cyan: #06b6d4;
  --purple: #8b5cf6;
  --glow-green: rgba(16,185,129,.35);
  --glow-red: rgba(239,68,68,.35);
  --glow-blue: rgba(59,130,246,.35);
  --radius: 14px;
  --radius-sm: 8px;
  --font: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
}

/* ============ reset / base ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  background:
    radial-gradient(ellipse at 15% 10%, rgba(59,130,246,.07) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 85%, rgba(139,92,246,.06) 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
button { font-family: var(--font); cursor: pointer; }
input, select { font-family: var(--font); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--blue); }
.hidden { display: none !important; }

.app-shell { max-width: 1440px; margin: 0 auto; padding: 14px 18px 40px; }

/* ============ top bar ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 6px 14px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 13px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: grid; place-items: center; font-weight: 900; font-size: 16px;
  color: #fff; box-shadow: 0 4px 18px var(--glow-blue);
}
.brand-name { font-weight: 800; font-size: 1.05rem; letter-spacing: .3px; }
.brand-tag { font-size: .7rem; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status-pill {
  display: flex; align-items: center; gap: 7px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 30px; font-size: .72rem; color: var(--text2);
  background: var(--card);
}
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.status-pill.online .dot { background: var(--green); box-shadow: 0 0 8px var(--glow-green); }
.status-pill.offline .dot { background: var(--red); box-shadow: 0 0 8px var(--glow-red); }
.clock { font-family: var(--mono); font-size: .82rem; color: var(--text2); }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--line); color: var(--text2);
  font-size: 1rem; display: grid; place-items: center; transition: .2s;
}
.icon-btn:hover { border-color: var(--blue); color: var(--text); }
.icon-btn .badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 10px; background: var(--red); color: #fff; font-size: .65rem; font-weight: 700;
  display: grid; place-items: center; box-shadow: 0 0 8px var(--glow-red);
}

/* ============ nav ============ */
.nav {
  display: flex; gap: 6px; flex-wrap: wrap; padding-bottom: 14px;
  border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.nav-tab {
  padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--text2); font-size: .82rem; font-weight: 600;
  transition: .2s;
}
.nav-tab:hover { background: var(--card); color: var(--text); }
.nav-tab.active {
  background: linear-gradient(135deg, rgba(59,130,246,.18), rgba(139,92,246,.14));
  border-color: var(--blue); color: var(--text); box-shadow: 0 0 14px rgba(59,130,246,.15);
}

/* ============ banner ============ */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; margin-bottom: 14px; border-radius: 10px;
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4);
  color: #fecaca; font-size: .8rem;
}
.banner-close { background: none; border: none; color: inherit; font-size: .9rem; }

/* ============ views ============ */
.view { display: none; animation: fadeIn .35s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* ============ panels / grids ============ */
.grid-2col { display: grid; grid-template-columns: minmax(0,2fr) minmax(320px,1fr); gap: 16px; margin-bottom: 16px; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: 0 4px 24px rgba(0,0,0,.25);
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.panel-head strong { font-size: .95rem; display: block; }
.panel-head .sub { font-size: .7rem; color: var(--muted); }
.panel-head.wrap { flex-wrap: wrap; }

/* ============ buttons & inputs ============ */
.btn {
  padding: 9px 16px; border-radius: 9px; border: none; font-size: .8rem; font-weight: 600;
  background: var(--blue); color: #fff; transition: .2s;
}
.btn:hover { filter: brightness(1.12); }
.btn.primary { background: linear-gradient(135deg, var(--blue), #2563eb); box-shadow: 0 2px 12px var(--glow-blue); }
.btn.ghost { background: var(--card2); border: 1px solid var(--line); color: var(--text2); }
.btn.ghost:hover { color: var(--text); border-color: var(--blue); }
.btn.ghost.danger:hover { border-color: var(--red); color: #fca5a5; }
.btn.sm { padding: 6px 12px; font-size: .74rem; }
.link-btn { background: none; border: none; color: var(--blue); font-size: .74rem; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.input {
  width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: .82rem; outline: none; transition: .2s;
}
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.input.select { appearance: none; cursor: pointer; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .74rem; color: var(--text2); font-weight: 600; }
.hint { font-size: .7rem; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* ============ stats bar ============ */
.stats-bar {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 10px; margin-bottom: 16px;
}
.stats-bar.sm { margin-bottom: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.stat-label { font-size: .68rem; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.stat-value { font-size: 1.25rem; font-weight: 800; font-family: var(--mono); }
.stat-sub { font-size: .66rem; color: var(--muted); margin-top: 2px; }
.stat-up { color: var(--green); }
.stat-down { color: var(--red); }

/* ============ tables ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .78rem; min-width: 640px; }
.table th {
  text-align: left; padding: 11px 12px; background: var(--bg2); color: var(--text2);
  font-size: .66rem; text-transform: uppercase; letter-spacing: .6px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid rgba(35,50,74,.5); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--card2); }
.table .mono { font-family: var(--mono); }
.buy-text { color: var(--green); font-weight: 800; }
.sell-text { color: var(--red); font-weight: 800; }
.hold-text { color: var(--gold); font-weight: 800; }
.row-btn { background: none; border: none; color: var(--muted); font-size: .9rem; padding: 2px 6px; border-radius: 6px; }
.row-btn:hover { color: var(--red); background: rgba(239,68,68,.12); }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: .64rem;
  font-weight: 700; letter-spacing: .4px;
}
.tag.buy { background: rgba(16,185,129,.15); color: var(--green); border: 1px solid rgba(16,185,129,.4); }
.tag.sell { background: rgba(239,68,68,.15); color: var(--red); border: 1px solid rgba(239,68,68,.4); }
.tag.hold { background: rgba(245,158,11,.15); color: var(--gold); border: 1px solid rgba(245,158,11,.4); }

/* ============ chart ============ */
.chart-opts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chart-opts .select { width: 130px; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  border: none; background: transparent; color: var(--text2); font-size: .68rem; font-weight: 600;
  padding: 5px 8px; border-radius: 6px; transition: .2s;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--blue); color: #fff; }
.chart-wrap { position: relative; cursor: crosshair; }
#chart { width: 100%; height: 460px; display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; }
.chart-info-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 7px 12px; margin-bottom: 8px; font-size: .72rem;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 9px;
  font-family: var(--mono);
}
.chart-info-row .ci-price { font-size: 1rem; font-weight: 800; color: var(--cyan); }
.chart-info-row .ci-item { color: var(--text2); white-space: nowrap; }
.chart-info-row .ci-item b { color: var(--text); font-weight: 700; }
.chart-info-row .ci-item.muted { color: var(--muted); }
.chart-info-row .ci-item.muted b { color: var(--text2); font-weight: 600; }
.chart-info-row .ci-sep { color: var(--muted); }
.chart-info-row .ci-src {
  margin-left: auto; padding: 2px 8px; border-radius: 20px;
  font-size: .62rem; font-weight: 700; letter-spacing: .4px;
  background: rgba(6,182,212,.12); color: var(--cyan); border: 1px solid rgba(6,182,212,.35);
  text-transform: uppercase;
}
.chart-info-row .ci-src.binance { background: rgba(245,158,11,.12); color: var(--gold); border-color: rgba(245,158,11,.35); }
.chart-hint { font-size: .66rem; color: var(--muted); margin-top: 6px; letter-spacing: .2px; }
.chart-tooltip {
  position: absolute; pointer-events: none; z-index: 10; padding: 9px 12px;
  background: rgba(10,15,26,.95); border: 1px solid var(--line2); border-radius: 10px;
  font-family: var(--mono); font-size: .7rem; color: var(--text); box-shadow: 0 8px 28px rgba(0,0,0,.55);
  min-width: 170px; max-width: 290px; word-break: break-word; line-height: 1.55;
}
.chart-tooltip .tt-title { font-weight: 800; margin-bottom: 4px; font-family: var(--font); }
.chart-tooltip .tt-row { display: flex; justify-content: space-between; gap: 14px; }
.chart-tooltip .tt-k { color: var(--muted); }
.chart-tooltip .tt-v { color: var(--text); font-weight: 700; }
.chart-tooltip .tt-v.green { color: var(--green); }
.chart-tooltip .tt-v.red { color: var(--red); }
.chart-tooltip .tt-v.cyan { color: var(--cyan); }
.chart-tooltip .tt-v.gold { color: var(--gold); }
.chart-tooltip .tt-v.purple { color: #a78bfa; }
/* ============ signal panel ============ */
.signal { display: flex; flex-direction: column; gap: 14px; }
.signal-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.signal-big { font-size: 2.4rem; font-weight: 900; letter-spacing: 1px; }
.signal-big.buy { color: var(--green); text-shadow: 0 0 30px var(--glow-green); }
.signal-big.sell { color: var(--red); text-shadow: 0 0 30px var(--glow-red); }
.signal-big.hold { color: var(--gold); text-shadow: 0 0 30px rgba(245,158,11,.35); }
.signal-price { text-align: right; }
.signal-price .label { font-size: .66rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.signal-price .val { font-family: var(--mono); font-size: 1.1rem; font-weight: 700; }
.conf { display: flex; align-items: center; gap: 10px; }
.conf .conf-label { font-size: .74rem; color: var(--text2); white-space: nowrap; }
.conf .conf-pct { font-family: var(--mono); font-weight: 700; font-size: .85rem; min-width: 38px; text-align: right; }
.conf-bar { flex: 1; height: 8px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.conf-fill { height: 100%; border-radius: 6px; transition: width .6s ease; }
.conf-fill.buy { background: linear-gradient(90deg, var(--green), #34d399); }
.conf-fill.sell { background: linear-gradient(90deg, var(--red), #f87171); }
.conf-fill.hold { background: linear-gradient(90deg, var(--gold), #fbbf24); }
.signal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sig-item { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; }
.sig-item .k { font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.sig-item .v { font-family: var(--mono); font-size: .84rem; font-weight: 700; margin-top: 2px; }
.sig-item .v.green { color: var(--green); }
.sig-item .v.red { color: var(--red); }
.sig-item .v.gold { color: var(--gold); }
.sig-item .v.cyan { color: var(--cyan); }
.center { text-align: center; }
.lvl { font-size: .72rem; color: var(--text2); margin-top: 4px; }
.lvl b { font-family: var(--mono); }
.factors { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.factor {
  font-size: .62rem; padding: 3px 8px; border-radius: 20px; border: 1px solid var(--line); color: var(--text2);
}
.factor.bull { border-color: rgba(16,185,129,.45); color: var(--green); background: rgba(16,185,129,.1); }
.factor.bear { border-color: rgba(239,68,68,.45); color: var(--red); background: rgba(239,68,68,.1); }
.signal-actions { display: flex; gap: 8px; margin-top: 4px; }

/* ============ info cards ============ */
.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-top: 16px; }
.info-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.info-card-head { font-size: .8rem; font-weight: 700; margin-bottom: 8px; }
.info-card-body { font-size: .74rem; color: var(--text2); line-height: 1.6; }
.info-card-body strong { color: var(--text); }

/* ============ forms ============ */
.add-form, .calc-form, .alert-form {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-top: 14px; align-items: end;
}
.calc-form { grid-template-columns: 1fr 1fr; }
.calc-result { grid-column: 1 / -1; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 4px; font-size: .78rem; color: var(--text2); }
.calc-result strong { font-family: var(--mono); color: var(--text); }
.totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.totals .t { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.totals .t .l { font-size: .62rem; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.totals .t .n { font-family: var(--mono); font-weight: 800; font-size: 1rem; }

/* ============ lists ============ */
.list-head { font-size: .78rem; font-weight: 700; margin: 18px 0 8px; display: flex; justify-content: space-between; align-items: center; }
.list { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.empty { color: var(--muted); font-size: .78rem; padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.notif-item {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font-size: .76rem; animation: slideIn .3s ease;
}
.notif-item.unread { border-left: 3px solid var(--blue); }
.notif-item .n-title { font-weight: 700; color: var(--text); display: flex; justify-content: space-between; gap: 8px; }
.notif-item .n-time { font-size: .62rem; color: var(--muted); font-family: var(--mono); white-space: nowrap; }
.notif-item .n-body { color: var(--text2); margin-top: 3px; line-height: 1.5; }
.notif-item.signal .n-title { color: var(--cyan); }
.notif-item.alert .n-title { color: var(--gold); }
.notif-item.paper-win .n-title { color: var(--green); }
.notif-item.paper-loss .n-title { color: var(--red); }
.alert-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: .76rem; }
.alert-row .a-main { display: flex; align-items: center; gap: 10px; }
.alert-row .a-symbol { font-weight: 800; font-family: var(--mono); }
.alert-row .a-triggered { opacity: .55; }
.alert-row.done { opacity: .55; }
/* ============ AI chat ============ */
.ai-layout { max-width: 860px; margin: 0 auto; }
.ai-panel { display: flex; flex-direction: column; min-height: calc(100vh - 240px); }
.ai-context {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; padding: 9px 11px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; font-size: .66rem; color: var(--muted);
}
.ai-context .ctx-chip { padding: 2px 8px; border-radius: 20px; background: var(--card2); border: 1px solid var(--line); color: var(--text2); }
.chat-thread { flex: 1; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; padding: 4px 0 14px; max-height: 55vh; }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 14px; font-size: .8rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; animation: msgIn .3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { align-self: flex-end; background: linear-gradient(135deg, var(--blue), #2563eb); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--bg2); border: 1px solid var(--line); border-bottom-left-radius: 4px; color: var(--text); white-space: normal; }
.msg.ai .think { color: var(--muted); font-style: italic; font-size: .74rem; }
.msg.ai p { margin: 0 0 8px; }
.msg.ai p:last-child { margin-bottom: 0; }
.msg.ai h1, .msg.ai h2, .msg.ai h3, .msg.ai h4, .msg.ai h5 { margin: 10px 0 6px; line-height: 1.35; color: var(--text); }
.msg.ai h1 { font-size: 1.08rem; } .msg.ai h2 { font-size: 1rem; } .msg.ai h3 { font-size: .94rem; }
.msg.ai h4 { font-size: .9rem; } .msg.ai h5 { font-size: .86rem; }
.msg.ai ul, .msg.ai ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.ai li { margin: 2px 0; }
.msg.ai code { background: rgba(6,182,212,.12); border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-family: var(--mono); font-size: .74rem; }
.msg.ai pre { background: #0a0f1a; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; margin: 8px 0; }
.msg.ai pre code { background: transparent; border: 0; padding: 0; font-size: .74rem; white-space: pre; }
.msg.ai blockquote { border-left: 3px solid var(--cyan); margin: 8px 0; padding: 4px 12px; color: var(--text2); }
.msg.ai a { color: var(--cyan); text-decoration: underline; }
.msg.ai hr { border: 0; border-top: 1px solid var(--line2); margin: 10px 0; }
.msg.ai b, .msg.ai strong { color: var(--text); }
.msg.ai h1:first-child, .msg.ai h2:first-child, .msg.ai h3:first-child, .msg.ai h4:first-child, .msg.ai h5:first-child, .msg.ai p:first-child { margin-top: 0; }
.msg.error { align-self: center; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; font-size: .74rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  background: var(--bg2); border: 1px solid var(--line); color: var(--text2); font-size: .7rem;
  padding: 6px 11px; border-radius: 20px; transition: .2s;
}
.chip:hover { border-color: var(--cyan); color: var(--text); }
.chat-input-row { display: flex; gap: 10px; }
.chat-input-row .input { flex: 1; }

/* AI level control */
.ai-controls { display: flex; align-items: center; gap: 8px; font-size: .72rem; color: var(--text2); }
.ai-controls .seg button { min-width: 0; }
.ai-ctl-label { font-weight: 600; }

/* Trade timing widget */
.timing-wrap {
  display: block; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg2); overflow: hidden;
}
.timing-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: .78rem; font-weight: 700; color: var(--cyan);
  background: var(--card); border-bottom: 1px solid var(--line);
}
.timing-body { padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; }
.timing-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: .7rem; }
.timing-k { color: var(--text2); font-weight: 600; }
.timing-days { display: flex; flex-wrap: wrap; gap: 5px; }
.timing-day {
  font-size: .64rem; padding: 2px 8px; border-radius: 12px;
  border: 1px solid var(--line); color: var(--text);
  background: var(--card2);
}
.timing-list { display: flex; flex-direction: column; gap: 4px; }
.timing-item { display: flex; justify-content: space-between; gap: 10px; font-size: .7rem; }
.timing-item.muted { color: var(--muted); }
.timing-t { font-family: var(--mono); color: var(--text); font-weight: 600; }
.timing-v { color: var(--text2); }
.timing-foot { font-size: .64rem; color: var(--muted); }

/* Image upload */
.upload-zone { margin-bottom: 8px; }
.upload-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.upload-hint { font-size: .64rem; color: var(--muted); }
.upload-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.upload-preview {
  position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  width: 84px; height: 56px; background: var(--bg2);
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-preview .row-btn {
  position: absolute; top: 2px; right: 2px; background: rgba(239,68,68,.85);
  color: #fff; border: none; border-radius: 50%; width: 16px; height: 16px; font-size: .6rem; line-height: 1;
}
/* In-message image */
.msg-img {
  display: block; margin-top: 6px; max-width: 220px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,.25);
}
.msg.user .msg-img { border-color: rgba(255,255,255,.35); }

/* ============ toasts ============ */
.toast-wrap { position: fixed; top: 16px; right: 16px; z-index: 400; display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.toast {
  background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 10px 32px rgba(0,0,0,.5); font-size: .78rem; animation: toastIn .4s ease;
  cursor: pointer; overflow: hidden; position: relative;
}
.toast .t-title { font-weight: 800; margin-bottom: 2px; }
.toast .t-body { color: var(--text2); line-height: 1.5; }
.toast::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.toast.signal::before { background: var(--cyan); }
.toast.alert::before { background: var(--gold); }
.toast.success::before, .toast.paper-win::before { background: var(--green); }
.toast.error::before, .toast.paper-loss::before { background: var(--red); }
.toast.out { animation: toastOut .4s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(100%); } }

/* ============ modal ============ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4,8,16,.72); backdrop-filter: blur(4px);
  z-index: 500; display: grid; place-items: center; animation: fadeIn .3s ease;
}
.modal {
  background: var(--card); border: 1px solid var(--line2); border-radius: 18px;
  max-width: 440px; width: calc(100% - 40px); padding: 26px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.modal-icon { font-size: 2.4rem; margin-bottom: 10px; }
.modal h3 { font-size: 1.15rem; margin-bottom: 10px; }
.modal p { font-size: .8rem; color: var(--text2); line-height: 1.6; }
.modal p.muted { font-size: .7rem; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }

/* ============ notification center ============ */
/* NOTE: panel sits ABOVE the blurred backdrop (z500) so the site is dimmed
   but never trapped underneath an unclickable blur overlay. */
.notice-panel {
  position: fixed; top: 70px; right: 16px; z-index: 520; width: 380px; max-width: calc(100vw - 32px);
  background: var(--card); border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 16px 50px rgba(0,0,0,.6);
  animation: fadeIn .25s ease;
}
.notice-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.notice-body { max-height: 430px; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }

/* ---- market mode switcher ---- */
.mode-switcher {
  display: flex; gap: 4px; padding: 3px; background: var(--line); border-radius: 999px;
  border: 1px solid var(--line2);
}
.mode-btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: .68rem; font-weight: 700; letter-spacing: .2px;
  padding: 5px 10px; border-radius: 999px; transition: all .18s ease; white-space: nowrap;
}
.mode-btn:hover { color: var(--text); }
.mode-btn.active { background: var(--cyan); color: #04121a; }

/* ---- device (OS) notification toggle ---- */
.notice-os-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 16px; border-bottom: 1px solid var(--line); background: rgba(6,182,212,.05);
}
.notice-os-label { display: flex; flex-direction: column; gap: 2px; }
.notice-os-label span { font-size: .78rem; font-weight: 700; color: var(--text); }
.notice-os-label em { font-style: normal; font-size: .66rem; color: var(--muted); }
.os-toggle {
  min-width: 58px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  background: var(--line2); color: var(--muted); border: 1px solid var(--line2);
  font-weight: 800; font-size: .72rem; letter-spacing: .5px; transition: all .2s ease;
}
.os-toggle:hover { border-color: var(--cyan); }
.os-toggle.os-on { background: var(--green); border-color: var(--green); color: #04120c; }
.os-toggle:disabled { opacity: .45; cursor: not-allowed; }
.notice-os-row.hidden { display: none; }

/* printable signal timing bar */
.pb-time { margin: 8px 0 10px; padding: 7px 11px; border-radius: 9px; background: rgba(52,211,153,.07); border: 1px solid var(--line); font-size: .72rem; color: var(--text2); }

/* ============ trade placement clock ============ */
.trade-clock { margin: 10px 0 12px; padding: 11px 13px; border-radius: 12px;
  background: linear-gradient(135deg, rgba(6,182,212,.09), rgba(52,211,153,.05));
  border: 1px solid var(--line2); }
.tc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.tc-title { font-size: .78rem; font-weight: 800; letter-spacing: .2px; }
.tc-tz { font-size: .6rem; color: var(--muted); background: rgba(127,127,127,.14); padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.tc-status { font-size: .8rem; margin-bottom: 9px; }
.tc-status b { color: var(--cyan); font-weight: 800; }
.tc-status.now b { color: var(--green); }
.tc-status em { font-style: normal; color: var(--text2); font-size: .7rem; margin-left: 4px; font-weight: 600; }
.tc-windows { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 9px; }
.tc-w { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; padding: 4px 10px;
  border-radius: 20px; background: rgba(127,127,127,.1); border: 1px solid var(--line); color: var(--text2); }
.tc-w.top { background: rgba(52,211,153,.15); border-color: rgba(52,211,153,.55); color: var(--text); font-weight: 700; }
.tc-w.top b { color: var(--green); }
.tc-w i { font-style: normal; font-size: .62rem; color: var(--muted); }
.tc-avoid { font-size: .66rem; color: var(--muted); margin-bottom: 8px; }
.tc-avoid b { color: var(--red); font-weight: 700; }
.tc-bar { height: 5px; border-radius: 10px; background: rgba(127,127,127,.16); overflow: hidden; margin-bottom: 9px; }
.tc-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, var(--cyan), var(--green)); transition: width .8s ease; }
.tc-foot { font-size: .66rem; color: var(--text2); display: flex; flex-wrap: wrap; gap: 10px; }

/* ============ login screen ============ */
.login-overlay {
  position: fixed; inset: 0; z-index: 9000; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(6,182,212,.18), transparent 60%),
              radial-gradient(900px 500px at 100% 110%, rgba(52,211,153,.12), transparent 55%),
              #05070d;
  animation: fadeIn .35s ease;
}
.login-card {
  width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line2);
  border-radius: 18px; padding: 30px 26px; text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.65);
  animation: loginPop .4s cubic-bezier(.2,.9,.3,1.2);
}
.login-logo { font-size: 3rem; margin-bottom: 8px; }
.login-title { font-size: 1.35rem; font-weight: 800; letter-spacing: .3px; }
.login-title .accent { color: var(--cyan); }
.login-sub { font-size: .72rem; color: var(--muted); margin: 6px 0 20px; letter-spacing: 1px; text-transform: uppercase; }
.login-field {
  width: 100%; padding: 13px 15px; border-radius: 12px; border: 1px solid var(--line2);
  background: var(--bg2); color: var(--text); font-size: .95rem; outline: none; transition: border-color .2s ease, box-shadow .2s ease;
}
.login-field:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(6,182,212,.18); }
.login-btn {
  width: 100%; margin-top: 14px; padding: 13px; border-radius: 12px; border: 0; cursor: pointer;
  background: linear-gradient(135deg, #06b6d4, #0891b2); color: #04121a; font-weight: 800; font-size: .95rem;
  transition: transform .15s ease, opacity .15s ease;
}
.login-btn:hover { transform: translateY(-1px); opacity: .94; }
.login-btn:active { transform: translateY(0); }
.login-error { color: var(--red); font-size: .78rem; margin-top: 12px; min-height: 1em; }
.login-hint { margin-top: 18px; font-size: .68rem; color: var(--muted); }
.login-loading { opacity: .6; pointer-events: none; }
@keyframes loginPop { from { opacity: 0; transform: scale(.92) translateY(10px); } to { opacity: 1; transform: none; } }

/* ============ auth tabs (Owner / User) ============ */
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg2); border: 1px solid var(--line2); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.auth-tab { padding: 9px 8px; border-radius: 9px; border: 0; background: transparent; color: var(--text2); font-weight: 700; font-size: .8rem; cursor: pointer; transition: background .15s ease, color .15s ease; }
.auth-tab.active { background: linear-gradient(135deg, rgba(6,182,212,.28), rgba(52,211,153,.22)); color: var(--text); box-shadow: inset 0 0 0 1px rgba(6,182,212,.4); }
.auth-form .login-field { margin-bottom: 10px; }
.login-btn.alt { background: linear-gradient(135deg, #34d399, #059669); color: #04120b; }
.login-btn.ghost { background: transparent; border: 1px solid var(--line2); color: var(--text2); font-weight: 700; }
.login-btn.sm { margin-top: 8px; padding: 9px; font-size: .82rem; }
.login-switch { margin-top: 14px; background: none; border: 0; color: var(--cyan); font-size: .76rem; font-weight: 700; cursor: pointer; text-decoration: underline dotted; }

/* ============ coin pill (top bar) ============ */
.coin-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px;
  background: linear-gradient(135deg, rgba(245,158,11,.18), rgba(6,182,212,.14));
  border: 1px solid rgba(245,158,11,.45); color: var(--text); font-size: .78rem; font-weight: 800; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease; }
.coin-pill:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(245,158,11,.25); }
.coin-pill b { color: var(--gold); font-size: .9rem; }
.coin-pill .coin-buy { font-size: .62rem; color: var(--muted); font-weight: 700; letter-spacing: .3px; }

/* ============ upgrade / buy coins ============ */
.plans { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; max-height: 52vh; overflow: auto; }
.plan-card { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px;
  padding: 12px 14px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line2); text-align: left; }
.plan-card .plan-name { font-size: .82rem; font-weight: 800; }
.plan-card .plan-coins { font-size: .72rem; color: var(--text2); }
.plan-card .plan-price { font-size: .9rem; font-weight: 800; color: var(--green); grid-column: 1; }
.plan-card .login-btn { margin-top: 0; grid-column: 2; grid-row: 1 / span 2; width: auto; padding: 9px 16px; }

/* ============ blurred signal lock (users pay 1 coin to reveal) ============ */
.signal-locked { position: relative; border-radius: 14px; overflow: hidden; }
.signal-locked .blur-inner { filter: blur(8px); pointer-events: none; user-select: none; opacity: .5; transform: scale(1.01); }
.signal-lock-veil { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 8px; text-align: center; padding: 18px;
  background: radial-gradient(600px 240px at 50% 0%, rgba(6,182,212,.12), transparent 70%), rgba(5,8,15,.6); }
.signal-lock-veil .lock-title { font-size: .92rem; font-weight: 800; }
.signal-lock-veil .lock-sub { font-size: .72rem; color: var(--text2); line-height: 1.5; }
.signal-lock-veil .lock-sub b { color: var(--gold); }
.signal-lock-veil .login-btn { width: auto; padding: 11px 22px; }
.signal-lock-veil .login-btn.sm { margin-top: 2px; }
.signal-table-locked { filter: blur(6px); pointer-events: none; user-select: none; opacity: .55; }
tr.row-locked td:not(.row-lock-cell) { filter: blur(5px); user-select: none; opacity: .6; }
tr.row-locked .row-lock-cell { min-width: 108px; text-align: center; }
.coin-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px;
  background: linear-gradient(135deg, rgba(245,158,11,.16), rgba(6,182,212,.12));
  border: 1px solid rgba(245,158,11,.4); font-size: .72rem; font-weight: 800; color: var(--text); }
.coin-chip b { color: var(--gold); }

/* ============ actionable playbook ============ */
.playbook { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: rgba(6,182,212,.05); border: 1px solid var(--line2); }
.playbook-wait { background: rgba(154,164,181,.06); border-color: var(--line); }
.pb-title { font-size: .82rem; font-weight: 800; margin-bottom: 8px; }
.pb-title .hold-text { color: var(--muted); }
.pb-steps { margin: 8px 0 10px; padding-left: 18px; }
.pb-steps li { font-size: .76rem; line-height: 1.65; margin: 5px 0; color: var(--text2); }
.pb-body { font-size: .76rem; line-height: 1.55; color: var(--text2); margin-bottom: 6px; }
.pb-alerts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pb-alerts-label { font-size: .7rem; color: var(--muted); font-weight: 700; }

/* ============ analytics / journal / guardrails / calendar ============ */
.acc-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.acc-col { display: flex; flex-direction: column; gap: 8px; }
.acc-head { font-size: .74rem; font-weight: 700; color: var(--text2); letter-spacing: .3px; text-transform: uppercase; }
.acc-tier { padding: 6px 10px; border-radius: 8px; background: var(--bg2); border: 1px solid var(--line); font-size: .74rem; }
.bt-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.bt-form label { display: flex; flex-direction: column; gap: 4px; font-size: .68rem; color: var(--muted); }
.bt-result { margin-top: 8px; }
.bt-result-inner { display: flex; flex-direction: column; gap: 6px; font-size: .74rem; }
.bt-line { padding: 6px 10px; border-radius: 8px; background: rgba(6,182,212,.06); border: 1px solid var(--line); }
.bt-line .ok { color: var(--green); font-weight: 800; }
.bt-line.sub { background: transparent; border: 0; color: var(--muted); }
.bt-recents { display: flex; flex-wrap: wrap; gap: 5px; }
.bt-chip { font-size: .66rem; padding: 3px 7px; border-radius: 4px; background: var(--bg2); border: 1px solid var(--line); }
.bt-chip.buy { color: var(--green); } .bt-chip.sell { color: var(--red); }
.equity-canvas { width: 100%; height: 210px; display: block; background: #0a0f1a; border: 1px solid var(--line2); border-radius: 12px; }
.journal-item { padding: 9px 11px; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.j-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.j-tag { font-size: .68rem; font-weight: 800; color: var(--cyan); }
.j-body { font-size: .76rem; color: var(--text2); line-height: 1.5; white-space: pre-wrap; }
.gu-line { padding: 6px 10px; border-radius: 8px; background: rgba(52,211,153,.06); border: 1px solid var(--line); font-size: .74rem; }
.gu-alert { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; font-size: .78rem; }
.cal-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); font-size: .74rem; flex-wrap: wrap; }
.cal-badge { font-size: .62rem; font-weight: 800; padding: 2px 6px; border-radius: 5px; }
.cal-badge.high { background: rgba(239,68,68,.18); color: #f87171; }
.cal-badge.med { background: rgba(234,179,8,.15); color: #facc15; }
.cal-time { font-family: var(--mono); color: var(--cyan); font-size: .68rem; min-width: 62px; }
.cal-title { flex: 1; color: var(--text); }
.cal-cc { color: var(--muted); font-size: .64rem; }
.cal-fc, .cal-pv { color: var(--muted); font-size: .66rem; font-family: var(--mono); }

/* ============ professional upgrades ============ */
/* signal tape marquee */
.signal-tape-wrap { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: rgba(9,13,22,.6); }
.signal-tape { display: flex; gap: 14px; padding: 8px 12px; white-space: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.signal-tape::-webkit-scrollbar { height: 4px; } .signal-tape::-webkit-scrollbar-thumb { background: var(--line2); }
.tape-item { font-size: .72rem; font-weight: 700; color: var(--text2); }
.tape-item.buy { color: var(--green); } .tape-item.sell { color: var(--red); } .tape-item.muted { color: var(--muted); }

/* stale signals */
tr.stale { opacity: .45; }
.signal.stale { opacity: .72; }

/* watchlist stars */
.row-btn.star { background: transparent; border: 0; color: var(--muted); font-size: .9rem; padding: 0 4px; cursor: pointer; }
.row-btn.star.on { color: #facc15; }

/* ribbons */
.ribbon { margin-bottom: 10px; padding: 8px 12px; border-radius: 9px; font-size: .74rem; font-weight: 700; }
.ribbon.news { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; }
.ribbon.cool { background: rgba(234,179,8,.1); border: 1px solid rgba(234,179,8,.35); color: #fde68a; }

/* accuracy by-symbol heading */
.acc-sub { font-size: .68rem; font-weight: 800; color: var(--muted); margin: 10px 0 5px; text-transform: uppercase; letter-spacing: .4px; }

/* compact pro layout */
body.pro-layout .app-shell { max-width: 1700px; padding: 10px 12px 24px; }
body.pro-layout .panel { padding: 10px 12px; }
body.pro-layout .table { font-size: .72rem; }
body.pro-layout .stat-card { padding: 8px 10px; }
body.pro-layout .signal-big { font-size: 1.6rem; }
body.pro-layout .pb-steps li { font-size: .72rem; }
body.pro-layout .factor { font-size: .62rem; }

.btn.active { border-color: var(--cyan); color: var(--cyan); }

/* ============ footer ============ */
.footer {
  text-align: center; padding: 18px 0 8px; color: var(--muted); font-size: .68rem;
  border-top: 1px solid var(--line); margin-top: 22px; letter-spacing: .3px;
}
.footer .mi-name { color: var(--cyan); font-weight: 700; }

/* ============ responsive ============ */
/* Tables scroll horizontally instead of breaking their layout on small screens. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 1100px) {
  .app-shell { padding: 12px 14px 32px; }
  .brand-tag { display: none; }
  .chart-info-row { flex-wrap: wrap; gap: 6px; }
  #chart { height: 380px; }
}

@media (max-width: 980px) {
  .grid-2col { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .ai-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .topbar { flex-wrap: wrap; gap: 8px; }
  .topbar-right { gap: 6px; }
  .brand-logo { width: 34px; height: 34px; font-size: 1rem; }
  .brand-name { font-size: .95rem; }
  .mode-switcher { order: 2; width: 100%; justify-content: center; }
  .status-pill { padding: 5px 9px; font-size: .68rem; }
  .clock { font-size: .72rem; }
  .nav { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-tab { white-space: nowrap; padding: 9px 12px; font-size: .75rem; }
  .app-shell { padding: 10px 10px 28px; }
  .panel { padding: 14px; }
  .panel-head { flex-wrap: wrap; gap: 8px; }
  .chart-opts { flex-wrap: wrap; }
  #chart { height: 320px; }
  .signal-grid { grid-template-columns: 1fr; }
  .signal-big { font-size: 1.9rem; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-value { font-size: 1.05rem; }
  .notice-panel { top: auto; bottom: 0; right: 8px; left: 8px; width: auto; max-width: none; border-radius: 14px 14px 0 0; max-height: 70vh; display: flex; flex-direction: column; }
  .notice-body { max-height: 44vh; }
  .modal { padding: 22px 18px; }
  .upload-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .chat-input-row { flex-wrap: wrap; }
  .timing-wrap { padding: 10px; }
}

@media (max-width: 480px) {
  .stats-bar { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .stat-label { font-size: .62rem; }
  .stat-value { font-size: .95rem; }
  .brand-tag { display: none; }
  .brand-name br { display: none; }
  .footer { font-size: .6rem; }
  .factor { font-size: .62rem; padding: 3px 6px; }
  .signal-price .val { font-size: 1.5rem; }
  .login-card { padding: 24px 18px; }
}