:root {
  --bg: #0d0d1a; --card: #17172b; --card2: #1e1e36; --line: #2a2a48;
  --text: #ecebf7; --muted: #9a98b8; --accent: #8b7bff; --green: #3ddc97; --red: #ff6b6b;
  --amber: #f5b942; --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; } .err { color: var(--red); }
h1 { margin: 8px 0; } h2 { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; font-weight: 600; }
main { padding: 0 16px 110px; max-width: 720px; margin: 0 auto; }
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: rgba(13,13,26,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.sym { font-weight: 700; font-size: 18px; } .price { color: var(--accent); margin-left: 6px; }
.icon-btn { background: var(--card); border: 1px solid var(--line); color: var(--text); width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; overflow-wrap: anywhere; }
.btn { background: var(--card2); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; font-size: 15px; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0d0d1a; }
.btn.small { padding: 6px 12px; font-size: 13px; } .btn.wide { width: 100%; margin-top: 10px; } .btn.ghost { background: transparent; }
.btn:disabled { opacity: .5; }
input, select, textarea { width: 100%; background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 12px; padding: 11px 12px; font-size: 16px; margin: 6px 0 10px; font-family: inherit; }
.form label { display: block; font-size: 13px; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 11px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
.pill.Bullish, .pill.long, .pill.win { color: var(--green); border-color: rgba(61,220,151,.4); background: rgba(61,220,151,.08); }
.pill.Bearish, .pill.short, .pill.loss { color: var(--red); border-color: rgba(255,107,107,.4); background: rgba(255,107,107,.08); }
.pill.Neutral { color: var(--muted); } .pill.exp { color: var(--amber); border-color: rgba(245,185,66,.4); }
.pill.tested { color: var(--accent); border-color: rgba(139,123,255,.4); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(13,13,26,.97); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
.tabs button { background: none; border: 0; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 14px; }
.tabs button span { font-size: 20px; } .tabs button.active { color: var(--accent); background: var(--card); }
/* signals */
.sig-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.kv div { background: var(--card2); border-radius: 12px; padding: 8px 10px; }
.kv b { display: block; font-family: ui-monospace, Menlo, monospace; font-size: 15px; }
.kv span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.r-pos { color: var(--green); } .r-neg { color: var(--red); }
/* analyze */
.tf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.tf-slot { background: var(--card); border: 1px dashed var(--line); border-radius: 14px; padding: 10px 6px; text-align: center; font-size: 13px; position: relative; min-height: 64px; }
.tf-slot.has { border-style: solid; border-color: var(--accent); }
.tf-slot input { position: absolute; inset: 0; opacity: 0; margin: 0; }
.tf-slot b { display: block; font-size: 15px; }
.list-item { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.list-item .bar { width: 6px; align-self: stretch; border-radius: 6px; background: linear-gradient(var(--accent), #4fa3ff); }
.list-item .t { font-weight: 700; } .list-item .s { color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.a-title { font-size: 26px; font-weight: 800; line-height: 1.2; margin: 6px 0; }
.tf-card { border-bottom: 1px solid var(--line); padding: 14px 0; } .tf-card:last-child { border-bottom: 0; }
.tf-card .row-between b { font-size: 18px; }
.eng h3 { color: var(--accent); font-size: 13px; letter-spacing: .14em; margin: 0 0 6px; text-transform: uppercase; }
.eng > div { border-bottom: 1px solid var(--line); padding: 12px 0; } .eng > div:last-child { border-bottom: 0; }
.levels { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lv { border-radius: var(--radius); padding: 14px; background: var(--card); font-family: ui-monospace, Menlo, monospace; font-size: 14px; }
.lv.buy { border: 1px solid rgba(61,220,151,.4); } .lv.sell { border: 1px solid rgba(255,107,107,.4); }
.lv h4 { margin: 0 0 8px; letter-spacing: .12em; } .lv.buy h4 { color: var(--green); } .lv.sell h4 { color: var(--red); }
.lv .k { color: var(--muted); font-size: 11px; margin-top: 8px; } .lv .sl { color: var(--red); } .lv .tp { color: var(--green); }
.plan-grid > div { display: grid; grid-template-columns: 110px 1fr; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.plan-grid > div:last-child { border-bottom: 0; } .plan-grid .k { color: var(--muted); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.disclaimer { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0; }
/* tables / stats */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-grid div { background: var(--card2); border-radius: 12px; padding: 10px; }
.stat-grid b { display: block; font-size: 18px; } .stat-grid span { font-size: 11px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
td, th { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; } th { color: var(--muted); font-weight: 500; }
.scen { background: var(--card2); border-radius: 12px; padding: 10px 12px; margin: 8px 0; }
.login-box { max-width: 360px; margin: 18vh auto 0; padding: 0 16px; text-align: center; }
.logo { width: 64px; height: 64px; margin: 0 auto; border-radius: 18px; display: grid; place-items: center; font-weight: 800; font-size: 26px;
  background: linear-gradient(135deg, #f5d36b, #b8892b); color: #1a1405; }
.toggle-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.toggle-row label { display: flex; align-items: center; gap: 6px; font-size: 14px; } .toggle-row input { width: auto; margin: 0; }

.sig-card { cursor: pointer; } .sig-card:hover { border-color: var(--accent); }
.ladder .rung { display: grid; grid-template-columns: 70px 1fr auto; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; margin-bottom: 6px; background: var(--card2); font-variant-numeric: tabular-nums; }
.ladder .rung span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.ladder .rung b { font-family: ui-monospace, Menlo, monospace; font-size: 16px; } .ladder .rung em { font-style: normal; color: var(--muted); }
.ladder .tp { box-shadow: inset 3px 0 0 var(--green); } .ladder .sl { box-shadow: inset 3px 0 0 var(--red); }
.ladder .en { box-shadow: inset 3px 0 0 var(--accent); } .ladder .ex { box-shadow: inset 3px 0 0 var(--amber); }

/* app shell: header + scrolling content + tab bar (no position:fixed, so iOS can't shift the menu) */
html, body { height: 100%; overflow: hidden; }
#app { display: flex; flex-direction: column; height: 100%; height: 100dvh; }
#app .top { position: relative; top: auto; flex: none; }
#app main { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  width: 100%; max-width: none; padding-bottom: 28px; }
#app main > * { max-width: 720px; margin-left: auto; margin-right: auto; }
#app .tabs { position: relative; flex: none; }
#login { height: 100%; overflow-y: auto; }
.cal-status { font-size: 13px; margin: 0 0 12px; }

#tradeTable table { font-size: 12px; }
#tradeTable td, #tradeTable th { white-space: nowrap; padding: 8px 6px; }
#tradeTable td:first-child { white-space: normal; min-width: 72px; }

/* news page */
.page-title { font-size: 30px; font-weight: 800; letter-spacing: -.01em; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 4px; margin: 14px 0 6px; }
.seg button { background: none; border: 1px solid transparent; color: var(--muted); padding: 9px 0; border-radius: 12px; font-size: 15px; font-weight: 600; }
.seg button.on { background: var(--card2); border-color: var(--line); color: var(--text); }
.pred { background: linear-gradient(160deg, #1b1b33, var(--card)); }
.pred-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.pred-name { color: var(--accent); text-transform: uppercase; letter-spacing: .14em; font-size: 13px; font-weight: 700; margin-right: 8px; }
.tag { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.pill.big { font-size: 15px; font-weight: 700; padding: 6px 14px; }
.pred-sum { font-size: 17px; margin: 12px 0; }
.pred-inputs { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 10px 0; }
.pred-inputs .lbl { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.inp { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 6px 0; }
.inp .nm { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inp .vals { font-family: ui-monospace, Menlo, monospace; font-size: 13px; } .inp .vals em { color: var(--muted); font-style: normal; }
.pred-note { margin: 10px 0 0; }
.up-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.up-row:last-child { border-bottom: 0; } .up-row > div:first-child { min-width: 0; } .up-t { font-weight: 600; }
.hist-call { display: flex; align-items: center; gap: 8px; flex: none; } .hist-call > span:last-child { font-size: 18px; }

/* tab bar flush to the bottom on iPhone */
#app .tabs { padding-top: 4px; padding-bottom: max(2px, calc(env(safe-area-inset-bottom, 0px) - 16px)); }
#app .tabs button { padding: 4px 0 2px; }
html, body, #app { background: var(--bg); }

.kv.two-col { grid-template-columns: 1fr 1fr; }
.kv b small { font-size: 12px; font-weight: 600; }
.ladder .now { box-shadow: inset 3px 0 0 #6fb7ff; }
.open-line { font-size: 20px; font-weight: 800; margin: 8px 2px 6px; font-variant-numeric: tabular-nums; }

/* live TradingView widgets */
.top-left { flex: 1; min-width: 0; }
.live-quote { height: 0; overflow: hidden; }
.live-quote.ok { height: 86px; margin: -8px 0 0 -10px; overflow: hidden; }
.live-quote.ok iframe { height: 86px !important; }
.live-quote.ok + .sym-fallback { display: none; }
.live-quote iframe { pointer-events: none; }
.live-chart::before { content: "Loading live chart…"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; }
.live-chart > * { position: relative; z-index: 1; }
.live-chart { position: relative; height: 340px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: var(--card); }
.live-chart .tradingview-widget-container, .live-chart .tradingview-widget-container__widget { height: 100%; }

/* no double-tap / pinch zoom on the app itself (charts keep their own zoom) */
html, body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
button, a, .sig-card, .list-item, .tabs button, .seg button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
