/* Options Desk — premium mobile-first dark UI (iPhone-style).
   Tokens first, then base, layout, components, screens. Dark only. */
:root {
  --bg: #080c13; --panel: #0f1520; --panel2: #172030; --panel3: #1e293b; --line: rgba(148, 163, 184, .14); --line2: rgba(148, 163, 184, .24);
  --text: #eaf0f8; --muted: #8592a6;
  --green: #1f8f4a; --green-t: #34d17a; --red: #c2342f; --red-t: #ff6b64; --blue: #2f6bf2; --blue-t: #6aa3ff; --amber: #e0a53a;
  --atm: rgba(59, 130, 246, .16); --itm: rgba(224, 165, 58, .06);
  --r: 16px; --r-sheet: 26px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --tabbar: 58px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body { overscroll-behavior-y: none; -webkit-touch-callout: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select { font-size: 16px; } /* prevents iOS zoom on focus */
a { color: var(--blue-t); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }
.up { color: var(--green-t); } .down { color: var(--red-t); } .muted { color: var(--muted); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 20; background: rgba(8, 12, 19, .82); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-bottom: 1px solid var(--line); padding: calc(8px + var(--safe-t)) 14px 8px; }
.top .row1 { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
.chip-acct { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; max-width: 64vw; padding: 0 12px 0 10px; border-radius: 20px; background: var(--panel2);
  border: 1px solid var(--line2); font-weight: 600; cursor: pointer; transition: transform .15s var(--ease); }
.chip-acct:active { transform: scale(.97); }
.chip-acct .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-acct svg.i { width: 14px; height: 14px; color: var(--muted); }
.mkt { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.mkt i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.mkt.open i { background: var(--green-t); box-shadow: 0 0 0 3px rgba(52, 209, 122, .2); animation: pulse 2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(52, 209, 122, 0); } }
.tickers { display: flex; gap: 18px; overflow-x: auto; scrollbar-width: none; margin: 6px auto 0; max-width: 760px; font-size: 12px; white-space: nowrap; align-items: baseline; }
.tickers::-webkit-scrollbar { display: none; }
.tickers b { font-size: 14px; margin: 0 4px; font-weight: 650; }
.tickers .tk { cursor: pointer; }

/* ---------- layout ---------- */
main { padding: 14px 14px calc(var(--tabbar) + var(--safe-b) + 28px); max-width: 760px; margin: 0 auto; min-height: 70vh; }
main > section { animation: rise .28s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.card { background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 60%), var(--panel); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 12px; overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .22); }
.card > .hd { display: flex; align-items: center; gap: 8px; padding: 14px 16px 0; font-weight: 650; }
.card > .bd { padding: 12px 16px 16px; }
details.card > summary { list-style: none; cursor: pointer; padding: 15px 16px; min-height: 48px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .2s var(--ease); }
details.card[open] > summary::after { transform: rotate(225deg); }
details.card > .bd { padding-top: 0; }
.section-title { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; margin: 20px 6px 8px; }
.page-title { font-size: 28px; font-weight: 750; letter-spacing: -.02em; margin: 2px 2px 12px; }

.hero { padding: 18px 16px; background: radial-gradient(120% 140% at 0% 0%, rgba(47, 107, 242, .18), transparent 60%), var(--panel); }
.hero .label { color: var(--muted); font-size: 13px; }
.hero .big { font-size: 34px; font-weight: 750; letter-spacing: -.02em; line-height: 1.15; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 14px; }
.stats.three { grid-template-columns: repeat(3, 1fr); }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-weight: 650; font-size: 16px; }
.pill { display: inline-block; padding: 4px 11px; border-radius: 14px; font-size: 12px; font-weight: 650; background: var(--panel2); border: 1px solid var(--line2); white-space: nowrap; }
.pill.up { border-color: rgba(52, 209, 122, .45); color: var(--green-t); background: rgba(52, 209, 122, .08); }
.pill.down { border-color: rgba(255, 107, 100, .45); color: var(--red-t); background: rgba(255, 107, 100, .08); }
.note { background: rgba(224, 165, 58, .09); border: 1px solid rgba(224, 165, 58, .32); color: #ecbc5a; border-radius: 14px; padding: 11px 13px; margin-bottom: 12px; font-size: 13px; }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); font-size: 14px; }
.empty svg.i { width: 34px; height: 34px; display: block; margin: 0 auto 8px; opacity: .55; }

.switch { position: relative; width: 56px; height: 32px; border-radius: 16px; background: var(--panel3); border: 1px solid var(--line2); cursor: pointer; flex: none; transition: background .2s; padding: 0; }
.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .4); transition: left .22s var(--ease); }
.switch.on { background: var(--green); border-color: var(--green); }
.switch.on::after { left: 26px; }
.tap { position: relative; } .tap::before { content: ''; position: absolute; inset: -6px; } /* bigger touch area without bigger look */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; padding: 0 18px; border-radius: 13px;
  background: var(--panel2); border: 1px solid var(--line2); cursor: pointer; font-weight: 650; transition: transform .12s var(--ease), filter .12s; }
.btn:active { transform: scale(.97); filter: brightness(1.15); }
.btn.block { width: 100%; }
.btn.primary { background: linear-gradient(180deg, #3b7bff, var(--blue)); border-color: transparent; color: #fff; }
.btn.buy { background: linear-gradient(180deg, #25a557, var(--green)); border-color: transparent; color: #fff; }
.btn.sell { background: linear-gradient(180deg, #db4a44, var(--red)); border-color: transparent; color: #fff; }
.btn.sm { min-height: 44px; padding: 0 14px; font-size: 14px; }
.btn:disabled { opacity: .5; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { gap: 6px; flex: none; min-height: 40px; padding: 0 15px; display: inline-flex; align-items: center; border-radius: 20px; background: var(--panel2); border: 1px solid var(--line); cursor: pointer; font-size: 14px; white-space: nowrap; }
.chip:active { background: var(--panel3); }
.seg { display: flex; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; flex: none; }
.seg button { flex: 1; min-height: 38px; border: 0; background: none; padding: 0 14px; border-radius: 9px; color: var(--muted); font-weight: 650; cursor: pointer; transition: background .2s, color .2s; }
.seg button.on { background: var(--panel3); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.field input, .field select, .inp { background: var(--panel2); border: 1px solid var(--line2); border-radius: 13px; padding: 10px 13px; color: var(--text); width: 100%; min-height: 46px; outline: none; }
.field input:focus, .field select:focus, .inp:focus { border-color: var(--blue-t); box-shadow: 0 0 0 3px rgba(106, 163, 255, .18); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.check { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text); padding: 10px 0; min-height: 44px; }
.check input { width: 22px; height: 22px; flex: none; accent-color: var(--blue); }
.days { display: flex; gap: 6px; }
.days label { flex: 1; text-align: center; padding: 12px 0; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); font-size: 13px; color: var(--text); cursor: pointer; }
.days input { display: none; }
.days label.on { background: var(--blue); border-color: var(--blue); color: #fff; }

.list > .item { padding: 13px 16px; border-top: 1px solid var(--line); }
.list > .item:first-child { border-top: 0; }
.item .l1 { display: flex; align-items: baseline; gap: 8px; }
.item .l1 .t { font-weight: 600; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.item .l2 { color: var(--muted); font-size: 13px; margin-top: 3px; overflow-wrap: anywhere; }
.item .pnl { font-weight: 700; white-space: nowrap; }
.item .acts { display: flex; gap: 8px; margin-top: 10px; }
.item .acts .btn { flex: 1; }
.day-h { padding: 8px 16px; font-size: 12px; font-weight: 650; color: var(--muted); background: rgba(255, 255, 255, .025); border-top: 1px solid var(--line); text-transform: uppercase; letter-spacing: .05em; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 7px; white-space: nowrap; }
.tag.buy { background: rgba(52, 209, 122, .14); color: var(--green-t); }
.tag.sell { background: rgba(255, 107, 100, .15); color: var(--red-t); }

.meter { position: relative; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--red), var(--line2) 50%, var(--green)); margin: 8px 0 12px; }
.meter i { position: absolute; top: -5px; width: 6px; height: 18px; background: #fff; border-radius: 3px; transform: translateX(-3px); transition: left .5s var(--ease); }
.factors { margin: 0 0 10px; padding: 0; list-style: none; font-size: 13.5px; }
.factors li { padding: 3px 0; }
.log { max-height: 320px; overflow: auto; font-size: 12.5px; }
.log div { padding: 7px 0; border-bottom: 1px dashed var(--line); }

/* flash when a number changes */
.flash-up { animation: fup .9s ease-out; } .flash-down { animation: fdn .9s ease-out; }
@keyframes fup { from { background: rgba(52, 209, 122, .35); } }
@keyframes fdn { from { background: rgba(255, 107, 100, .35); } }

/* skeleton loaders */
.skel { border-radius: var(--r); background: linear-gradient(90deg, var(--panel) 25%, var(--panel2) 50%, var(--panel) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; border: 1px solid var(--line); }
.skel.h1 { height: 120px; margin-bottom: 12px; } .skel.h2 { height: 76px; margin-bottom: 12px; } .skel.h3 { height: 200px; margin-bottom: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* option chain */
.chain-ctl { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.chain-ctl select { flex: 1; min-width: 0; }
.chain { width: 100%; border-collapse: collapse; font-size: 14px; }
.chain th { color: var(--muted); font-weight: 600; font-size: 11.5px; padding: 9px 6px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
.chain td { padding: 11px 6px; text-align: right; border-top: 1px solid var(--line); white-space: nowrap; }
.chain td.k { text-align: center; font-weight: 700; background: var(--panel2); }
.chain .pe-l { text-align: left; }
.chain tr { cursor: pointer; }
.chain tbody tr:active td { background: var(--panel3); }
.chain tr.atm td { background: var(--atm); }
.chain td.itm { background: var(--itm); }
.chain .oi { position: relative; color: var(--muted); font-size: 12px; }
.chain .oi i { position: absolute; top: 7px; bottom: 7px; opacity: .28; border-radius: 3px; }
.chain .oi.ce i { right: 0; background: var(--red-t); }
.chain .oi.pe i { left: 0; background: var(--green-t); }
.chain .oi span { position: relative; }
.chain small { display: block; font-size: 11px; }
.chain-wrap { max-height: 62vh; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* bottom tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; background: rgba(10, 15, 24, .82); backdrop-filter: saturate(1.6) blur(20px);
  -webkit-backdrop-filter: saturate(1.6) blur(20px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabbar button { flex: 1; max-width: 190px; height: var(--tabbar); border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; cursor: pointer; position: relative; transition: color .2s, transform .12s var(--ease); }
.tabbar button:active { transform: scale(.92); }
.tabbar button svg { width: 25px; height: 25px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s var(--ease); }
.tabbar button.on { color: var(--blue-t); }
.tabbar button.on svg { transform: translateY(-1px) scale(1.08); }
.tabbar .badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; font-weight: 700; }

/* bottom sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s; transition: opacity .2s; }
.sheet { background: var(--panel); border: 1px solid var(--line2); border-bottom: 0; width: 100%; max-width: 560px; max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0; padding: 0 18px calc(18px + var(--safe-b)); animation: up .34s var(--ease); will-change: transform; }
.sheet .grab { position: sticky; top: 0; height: 28px; margin: 0 -18px 4px; display: flex; align-items: center; justify-content: center; background: var(--panel); touch-action: none; z-index: 2; }
.sheet .grab::before { content: ''; width: 40px; height: 5px; border-radius: 3px; background: var(--line2); }
.sheet.closing { transition: transform .22s ease-in; transform: translateY(100%); }
.sheet h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.01em; }
.sheet .acts { display: flex; gap: 10px; margin-top: 16px; }
.sheet .acts .btn { flex: 1; }
@keyframes up { from { transform: translateY(60px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
@media (min-width: 700px) { .sheet-bg { align-items: center; } .sheet { border-radius: var(--r-sheet); border-bottom: 1px solid var(--line2); } }

.pick { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); margin-bottom: 8px; cursor: pointer; min-height: 60px; }
.pick.on { border-color: var(--blue-t); background: rgba(47, 107, 242, .12); }
.pick .ic { width: 38px; height: 38px; border-radius: 11px; background: var(--panel3); display: grid; place-items: center; flex: none; }

.toast { position: fixed; left: 14px; right: 14px; bottom: calc(var(--tabbar) + var(--safe-b) + 14px); margin: 0 auto; max-width: 520px; background: rgba(30, 41, 59, .96); backdrop-filter: blur(14px);
  border: 1px solid var(--line2); padding: 13px 15px; border-radius: 14px; z-index: 60; box-shadow: 0 12px 32px rgba(0, 0, 0, .5); animation: up .3s var(--ease); }
.toast.err { border-color: var(--red); }

/* menu rows (Account) */
.menu .item { display: flex; align-items: center; gap: 14px; padding: 0 16px; min-height: 56px; border-top: 1px solid var(--line); cursor: pointer; font-weight: 550; }
.menu .item:first-child { border-top: 0; }
.menu .item:active { background: var(--panel2); }
.menu .item .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--blue); color: #fff; flex: none; }
.menu .item .ic svg.i { width: 18px; height: 18px; }
.menu .item .ic.g { background: var(--green); } .menu .item .ic.o { background: #d9822b; } .menu .item .ic.p { background: #7b5cf0; } .menu .item .ic.r { background: var(--red); } .menu .item .ic.s { background: #4b5a72; }
.menu .item::after { content: ''; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-top: 2px solid var(--muted); transform: rotate(45deg); opacity: .7; }
.menu .item.plain::after { display: none; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--blue-t); background: none; border: 0; min-height: 44px; padding: 0 8px 0 0; font-size: 16px; cursor: pointer; margin-bottom: 2px; }
.back svg.i { width: 22px; height: 22px; }
.avatar { width: 56px; height: 56px; border-radius: 16px; flex: none; }

/* pull to refresh */
.ptr { height: 0; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; color: var(--muted); font-size: 12px; transition: height .2s var(--ease); }
.ptr.pull { transition: none; }
.ptr svg.i { width: 18px; height: 18px; margin-bottom: 6px; transition: transform .2s; }
.ptr.ready svg.i { transform: rotate(180deg); }
.ptr.busy svg.i { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

svg text { fill: var(--muted); font-size: 10px; }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 18px; background: radial-gradient(90% 60% at 50% 0%, rgba(47, 107, 242, .22), transparent 70%), var(--bg); }
.login form { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.login .logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 2px; display: block; box-shadow: 0 12px 36px rgba(47, 107, 242, .35); }
.login h1 { margin: 0; font-size: 28px; letter-spacing: -.02em; text-align: center; }
.login .sub { text-align: center; color: var(--muted); margin-top: -8px; }
.login #err { color: var(--red-t); min-height: 1.3em; font-size: 14px; text-align: center; }
.login .pwrow { position: relative; }
.login .pwrow button { position: absolute; right: 4px; top: 2px; min-height: 42px; padding: 0 12px; border: 0; background: none; color: var(--blue-t); font-weight: 650; cursor: pointer; }
.login .pwrow .inp { padding-right: 70px; }

@media (min-width: 700px) { .tabbar { left: 50%; right: auto; width: 520px; transform: translateX(-50%); border-radius: 22px 22px 0 0; border: 1px solid var(--line); } }
