/* ===========================================================================
   stock — modern web UI
   =========================================================================== */
:root {
  --bg:        #0a0d14;
  --bg-grad:   radial-gradient(1200px 600px at 80% -10%, #15203a 0%, transparent 55%),
               radial-gradient(900px 500px at -10% 110%, #1a1430 0%, transparent 50%), #0a0d14;
  --surface:   #11161f;
  --surface-2: #161c28;
  --surface-3: #1c2433;
  --border:    #222b3a;
  --border-2:  #2c374a;
  --text:      #eaf0f8;
  --dim:       #9aa7bd;
  --faint:     #6b7689;
  --brand:     #5b8cff;
  --brand-2:   #8b5cff;
  --brand-grad: linear-gradient(135deg, #5b8cff, #8b5cff);
  --green:     #34d399;
  --green-d:   #10b981;
  --red:       #f87171;
  --red-d:     #ef4444;
  --amber:     #fbbf24;
  --r:   12px;
  --r-lg: 18px;
  --r-sm: 9px;
  --shadow: 0 10px 30px -12px rgba(0,0,0,.6);
  --shadow-lg: 0 24px 60px -20px rgba(0,0,0,.7);
  --glass: rgba(13,17,25,.7);
  --glass-top: rgba(10,13,20,.72);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Light theme ---------- */
html[data-theme="light"] {
  --bg:        #f5f7fb;
  --bg-grad:   radial-gradient(1100px 560px at 85% -12%, #e7eefc 0%, transparent 55%),
               radial-gradient(900px 480px at -10% 110%, #efeafe 0%, transparent 50%), #f5f7fb;
  --surface:   #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e6ebf3;
  --border:    #e3e8f0;
  --border-2:  #cdd6e4;
  --text:      #0f1830;
  --dim:       #4a5568;
  --faint:     #8593a8;
  --green:     #0f9d58;
  --red:       #e0413a;
  --amber:     #c2790a;
  --shadow:    0 8px 24px -14px rgba(20,40,90,.25);
  --shadow-lg: 0 22px 50px -24px rgba(20,40,90,.3);
  --glass:     rgba(255,255,255,.78);
  --glass-top: rgba(255,255,255,.8);
}
html[data-theme="light"] .verdict.LONG { background: linear-gradient(135deg, rgba(15,157,88,.1), transparent 70%); }
html[data-theme="light"] .verdict.SHORT { background: linear-gradient(135deg, rgba(224,65,58,.1), transparent 70%); }
html[data-theme="light"] .btn.primary { box-shadow: 0 8px 18px -8px rgba(91,140,255,.55); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg-grad); background-attachment: fixed;
  color: var(--text); font-family: var(--sans); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); }
.dim { color: var(--dim); } .faint { color: var(--faint); }
.green { color: var(--green); } .red { color: var(--red); } .amber { color: var(--amber); }
.center { text-align: center; }
svg.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Login ---------- */
#login {
  position: fixed; inset: 0; display: grid; place-items: center; z-index: 200; padding: 20px;
  background: var(--bg-grad);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 32px; box-shadow: var(--shadow-lg);
}
.login-card .logo { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.login-card h1 { font-size: 19px; margin: 0; font-weight: 700; }
.login-card p { color: var(--dim); margin: 0 0 22px; font-size: 13px; }

/* ---------- Shell ---------- */
#app { display: grid; grid-template-columns: 248px 1fr; grid-template-rows: 100vh; }
#sidebar {
  background: var(--glass); backdrop-filter: blur(12px); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 18px; }
.brand .mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand-grad); display: grid; place-items: center; box-shadow: 0 6px 18px -6px var(--brand); }
.brand .mark svg { width: 19px; height: 19px; stroke: #fff; }
.brand .name { font-weight: 750; font-size: 16px; letter-spacing: -.2px; }
.brand .name small { display: block; font-size: 10.5px; color: var(--faint); font-weight: 500; letter-spacing: .3px; }

nav.menu { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
nav.menu a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-sm);
  color: var(--dim); cursor: pointer; font-weight: 550; font-size: 13.5px; transition: all .14s;
}
nav.menu a:hover { background: var(--surface-2); color: var(--text); }
nav.menu a.active { background: var(--surface-3); color: var(--text); }
nav.menu a.active svg { stroke: var(--brand); }
.menu-label { padding: 16px 12px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--faint); font-weight: 700; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); }
.side-foot .acct { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r-sm); }
.side-foot .acct .av { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; color: var(--brand); font-weight: 700; }

/* ---------- Topbar ---------- */
#main { overflow-y: auto; height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: var(--glass-top); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .hb { display: none; background: none; border: none; color: var(--text); cursor: pointer; padding: 4px; }
.topbar h2 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: -.2px; }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.chip .dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.chip .dot.red { background: var(--red); }
.chip.equity { color: var(--text); } .chip.equity b { font-family: var(--mono); }

.content { padding: 26px 28px 60px; max-width: 1180px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 700; }
.card .sub { color: var(--dim); font-size: 12.5px; margin: 0 0 16px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--dim); text-transform: uppercase; letter-spacing: .6px; margin: 26px 2px 12px; }

/* stat card */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat .label { color: var(--faint); font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat .label svg { width: 15px; height: 15px; }
.stat .val { font-size: 26px; font-weight: 750; font-family: var(--mono); letter-spacing: -.5px; }
.stat .meta { font-size: 12px; color: var(--dim); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 650; color: var(--dim); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 140px; margin-bottom: 0; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border-2); color: var(--text);
  border-radius: var(--r-sm); padding: 11px 13px; font-size: 14px; font-family: inherit; transition: border-color .14s, box-shadow .14s;
}
input:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91,140,255,.15); }
input.big { font-size: 18px; font-weight: 650; letter-spacing: .5px; text-transform: uppercase; }

/* segmented toggle */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 3px; gap: 3px; }
.seg button { flex: 1; background: none; border: none; color: var(--dim); padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; font-family: inherit; white-space: nowrap; }
.seg button.on { background: var(--surface-3); color: var(--text); }

/* strategy chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .chipbtn {
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--border-2); background: var(--bg);
  color: var(--dim); cursor: pointer; font-size: 12.5px; font-weight: 600; transition: all .14s; user-select: none;
}
.chips .chipbtn.on { background: rgba(91,140,255,.14); border-color: var(--brand); color: #cdd9ff; }

details.adv { margin-top: 6px; border-top: 1px dashed var(--border); padding-top: 12px; }
details.adv summary { cursor: pointer; color: var(--dim); font-size: 12.5px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 6px; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv[open] summary svg { transform: rotate(90deg); }
details.adv summary svg { transition: transform .15s; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border: none; border-radius: var(--r-sm); padding: 11px 18px; font-size: 13.5px; font-weight: 650;
  font-family: inherit; transition: filter .14s, transform .05s; white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--brand-grad); color: #fff; box-shadow: 0 8px 20px -8px var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { background: var(--red-d); color: #fff; }
.btn.sm { padding: 7px 12px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn .spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Badges / verdict ---------- */
.dir { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12px; font-weight: 750; letter-spacing: .3px; }
.dir.LONG { background: rgba(52,211,153,.16); color: var(--green); }
.dir.SHORT { background: rgba(248,113,113,.16); color: var(--red); }
.dir.FLAT { background: rgba(154,167,189,.14); color: var(--dim); }

.verdict { display: flex; align-items: center; gap: 18px; padding: 22px; border-radius: var(--r-lg); border: 1px solid var(--border-2); }
.verdict.LONG { background: linear-gradient(135deg, rgba(52,211,153,.12), transparent 70%); border-color: rgba(52,211,153,.35); }
.verdict.SHORT { background: linear-gradient(135deg, rgba(248,113,113,.12), transparent 70%); border-color: rgba(248,113,113,.35); }
.verdict.FLAT { background: var(--surface-2); }
.verdict .big { font-size: 34px; font-weight: 800; letter-spacing: -.5px; }
.verdict.LONG .big { color: var(--green); } .verdict.SHORT .big { color: var(--red); } .verdict.FLAT .big { color: var(--dim); }

/* contract ticket */
.ticket { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 20px; padding: 18px; background: var(--surface-2); border-radius: var(--r); border: 1px solid var(--border); margin-top: 14px; }
.ticket .t-k { font-size: 11px; color: var(--faint); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.ticket .t-v { font-size: 16px; font-weight: 700; font-family: var(--mono); margin-top: 2px; }

/* ---------- Tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; color: var(--faint); font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--border-2); }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); }
.tbl tr:hover td { background: var(--surface-2); }
.bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--brand-grad); }

/* feed list (run loop / journal) */
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 420px; overflow-y: auto; }
.feed .item { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 11px 13px; font-size: 12.5px; }
.feed .item .t { color: var(--faint); font-family: var(--mono); font-size: 11px; }

/* empty / loading */
.empty { text-align: center; padding: 40px 20px; color: var(--faint); }
.empty svg { width: 34px; height: 34px; opacity: .5; margin-bottom: 10px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; height: 16px; }
@keyframes sk { to { background-position: -200% 0; } }

/* note banners */
.note { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm); font-size: 12.5px; margin: 12px 0; align-items: flex-start; }
.note svg { flex: none; width: 17px; height: 17px; margin-top: 1px; }
.note.warn { background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.3); color: #f7d98a; }
.note.danger { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); color: #f6a9a9; }
.note.info { background: rgba(91,140,255,.1); border: 1px solid rgba(91,140,255,.3); color: #b9ccff; }

/* ---------- Modal ---------- */
#modal-bg { position: fixed; inset: 0; background: rgba(5,7,12,.66); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow-lg); }
.modal h3 { margin: 0 0 8px; font-size: 17px; }
.modal p { color: var(--dim); font-size: 13.5px; margin: 0 0 18px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface-3); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 12px 16px; font-size: 13px; box-shadow: var(--shadow-lg); display: flex; gap: 10px; align-items: center; animation: tin .2s ease; max-width: 340px; }
.toast.ok { border-left: 3px solid var(--green); } .toast.err { border-left: 3px solid var(--red); } .toast.info { border-left: 3px solid var(--brand); }
@keyframes tin { from { opacity: 0; transform: translateX(20px); } }

/* ---------- Help ---------- */
.guide { max-width: 800px; line-height: 1.7; }
.guide h2 { font-size: 17px; margin: 28px 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.guide h3 { font-size: 14.5px; margin: 18px 0 4px; color: var(--text); }
.guide code { font-family: var(--mono); background: var(--surface-3); padding: 2px 6px; border-radius: 5px; font-size: 12.5px; }
.guide pre { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 14px; overflow: auto; font-size: 12.5px; }
.guide ul { padding-left: 20px; } .guide li { margin: 4px 0; }
.toc { display: flex; flex-wrap: wrap; gap: 8px; }
.toc a { background: var(--surface-2); border: 1px solid var(--border); padding: 6px 12px; border-radius: 999px; font-size: 12.5px; color: var(--dim); }
.toc a:hover { color: var(--text); border-color: var(--border-2); }

/* ---------- Help tooltip ("?" badge) ---------- */
.hint { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px;
  border: 0; padding: 0; font-family: inherit; border-radius: 50%; background: var(--surface-3); color: var(--dim);
  font-size: 10px; font-weight: 700; cursor: help; margin-left: 5px; vertical-align: middle; position: relative;
  user-select: none; line-height: 1; }
.hint:hover, .hint:focus, .hint.open { background: var(--brand); color: #fff; }
.hint:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.hint .tip { display: none; position: absolute; bottom: 155%; left: 50%; transform: translateX(-50%);
  width: 230px; max-width: 62vw; background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text);
  font-size: 12px; font-weight: 500; line-height: 1.45; padding: 9px 11px; border-radius: 8px;
  box-shadow: var(--shadow-lg); z-index: 200; white-space: normal; text-align: left; text-transform: none; letter-spacing: 0; }
.hint:hover .tip, .hint:focus .tip, .hint.open .tip { display: block; }

/* ---------- News feed ---------- */
.newsfeed { display: flex; flex-direction: column; }
.newsitem { display: block; padding: 11px 4px; border-bottom: 1px solid var(--border-2); text-decoration: none; }
.newsitem:last-child { border-bottom: none; }
.newsitem:hover .nt { color: var(--brand); }
.newsitem .nt { color: var(--text); font-size: 13.5px; font-weight: 550; line-height: 1.4; }
.newsitem .nm { color: var(--faint); font-size: 11.5px; margin-top: 3px; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 80; transform: translateX(-100%); transition: transform .22s; }
  #sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .topbar .hb { display: block; }
  .cols-4 { grid-template-columns: repeat(2, 1fr); }
  .cols-3, .cols-2 { grid-template-columns: 1fr; }
  .ticket { grid-template-columns: repeat(2, 1fr); }
  #scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 70; }
}
@media (min-width: 921px) { #scrim { display: none; } }
