:root {
  /* NeoTrade 5 theme (owner 21 Nov: logo B "Sunset Flame") - plum night + flame orange, green candles for up */
  /* light theme (owner 21 Nov) - darker orange/green/red for text so they read on white */
  --bg: #F6F5FA; --surface: #FFFFFF; --surface2: #F1EEF8; --line: #E2DDEE; --fg: #1C1530; --muted: #6B6385;
  --accent: #E8650A; --flame: linear-gradient(90deg, #FF4D1C, #FF8A00, #FFC300); --buy: #1F6FEB; --sell: #E0284A; --up: #0E9F5A; --down: #E0284A; --warn: #B7791F;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; cursor: pointer; }
input, select { font: inherit; background: var(--bg); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.muted { color: var(--muted); }
.up { color: var(--up); } .down { color: var(--down); }
small { color: var(--muted); font-size: .75rem; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; }
.brand div { display: grid; }
.sum { display: flex; align-items: center; gap: 16px; }
.sum div { display: grid; text-align: right; }
.sum b { font-variant-numeric: tabular-nums; }
.pill { font-size: .75rem; padding: 3px 10px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--line); white-space: nowrap; }
.pill.live { color: var(--up); border-color: var(--up); }
.pill.off { color: var(--warn); border-color: var(--warn); }

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--accent); }
.tabs span { font-size: .75rem; color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.tab { display: none; } .tab.on { display: grid; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 1rem; }
.banner { background: #FFF6E0; border: 1px solid #F2C14E; color: #7A4E00; border-radius: 10px; padding: 8px 12px; font-size: .88rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface2); border-radius: 10px; padding: 10px 12px; display: grid; }
.stat b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 8px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; }
th:first-child, td:first-child { text-align: left; }
tr.closed td { color: var(--muted); }
tfoot td { font-weight: 600; border-bottom: 0; }

.list { display: grid; }
.wrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.wrow:last-child { border-bottom: 0; }
.wrow .nm { display: grid; min-width: 0; }
.wrow .nm b { overflow: hidden; text-overflow: ellipsis; }
.wrow .px { text-align: right; display: grid; font-variant-numeric: tabular-nums; }
.bs { display: flex; gap: 6px; }
.b, .s { border: 0; border-radius: 6px; padding: 5px 12px; color: #fff; font-weight: 600; font-size: .85rem; }
.b { background: var(--buy); } .s { background: var(--sell); }
.x { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 4px 8px; }
.star { background: none; border: 0; color: var(--muted); font-size: 1.1rem; padding: 2px 6px; }
.star.on { color: var(--warn); }
.link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { background: var(--surface2); border: 1px solid var(--line); color: var(--fg); border-radius: 999px; padding: 5px 12px; font-size: .82rem; }
.chips button:hover { border-color: var(--accent); }
.segbar { max-width: 420px; }
.search input { font-size: 1rem; padding: 10px 12px; }
.uhead { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0 8px; gap: 8px; flex-wrap: wrap; }
.uhead h2 { margin: 0; font-size: 1.2rem; }
.sub { margin: 14px 0 6px; color: var(--muted); font-size: .85rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sub select { width: auto; }
.chain td { padding: 6px; }
.chain td.k { text-align: center; font-weight: 600; background: var(--surface2); }
.chain tr.atm td.k { color: var(--accent); }
.chain td.cell { cursor: pointer; }
.chain td.cell:hover { background: var(--surface2); }
.chain tr.itmc td.ce, .chain tr.itmp td.pe { background: rgba(255, 170, 0, .09); }
.chain th { text-align: center; }
.cbs { display: inline-flex; gap: 4px; margin-left: 6px; }
.cbs button { padding: 2px 7px; font-size: .75rem; }

.modal { position: fixed; inset: 0; background: rgba(28, 21, 48, .38); display: grid; place-items: end center; z-index: 20; }
.modal[hidden] { display: none; }
.sheet { width: 100%; max-width: 460px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px 16px 0 0; max-height: 92vh; overflow: auto; }
@media (min-width: 700px) { .modal { place-items: center; } .sheet { border-radius: 16px; } }
.thead { padding: 14px 16px; border-bottom: 1px solid var(--line); display: grid; gap: 2px; }
.thead.buy { border-top: 4px solid var(--buy); } .thead.sell { border-top: 4px solid var(--sell); }
.tbody { padding: 14px 16px; display: grid; gap: 12px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); padding: 7px 4px; border-radius: 7px; font-size: .88rem; }
.seg button.on { background: var(--surface2); color: var(--fg); }
#tSide button.on[data-v="B"] { background: var(--buy); color: #fff; }
#tSide button.on[data-v="S"] { background: var(--sell); color: #fff; }
.row2[hidden] { display: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: grid; gap: 4px; font-size: .8rem; color: var(--muted); }
label[hidden] { display: none; }
.est { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: .85rem; display: grid; gap: 4px; }
.est div { display: flex; justify-content: space-between; }
.msg { margin: 0; min-height: 1.2em; color: var(--sell); font-size: .88rem; }
.actions { display: flex; gap: 10px; }
.actions button { flex: 1; padding: 11px; border-radius: 10px; border: 0; font-weight: 600; }
.ghost { background: var(--surface2); color: var(--fg); }
.go { background: var(--buy); color: #fff; } .go.sell { background: var(--sell); }
.go:disabled { opacity: .5; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: calc(100% - 32px); }
.toast.err { border-color: var(--sell); }
.foot { text-align: center; color: var(--muted); font-size: .78rem; padding: 20px 16px 32px; }

.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; align-items: end; }
.form button, .btn { background: var(--flame); color: #1A0D00; border: 0; border-radius: 8px; padding: 9px 14px; font-weight: 600; }
.btn.small { padding: 4px 10px; font-size: .8rem; }
.btn.warn { background: var(--sell); color: #fff; }
.btn.grey { background: var(--surface2); color: var(--fg); }
.tag { font-size: .7rem; padding: 1px 6px; border-radius: 4px; background: var(--surface2); color: var(--muted); margin-left: 4px; }
.tag.MIS { color: var(--warn); } .tag.NRML { color: var(--accent); }
.tag.B { color: var(--buy); } .tag.S { color: var(--sell); }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.head-row h3 { margin: 0; }

.cred { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; user-select: all; }
.cred div { display: grid; }
.cred b { word-break: break-all; }
.cred .pw { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; letter-spacing: .04em; color: var(--accent); }
.mob { display: none; }
.pcard { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.pcard.closed { opacity: .6; }
.pcard .pr { display: grid; justify-items: end; gap: 4px; text-align: right; white-space: nowrap; }
.pcard.tot { border-bottom: 0; align-items: center; }
@media (max-width: 600px) {
  .mob { display: block; } .desk { display: none; }
  .top { padding: 8px 16px; }
  .brand small { display: none; }
  .sum { gap: 10px; }
  main { padding: 12px 16px; }
  th, td { padding: 7px 6px; font-size: .85rem; }
}

/* admin viewing a friend's screen: read-only */
.viewbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: #FFF1D6; color: #7A4E00; border-bottom: 1px solid #F2C14E; padding: 8px 16px; font-size: .9rem; position: sticky; top: 56px; z-index: 4; }
.viewbar[hidden] { display: none; }
.viewas .b, .viewas .s, .viewas .star, .viewas .x, .viewas #exitAll, .viewas [data-exit], .viewas [data-add], .viewas [data-sltgt], .viewas [data-mod], .viewas [data-cancel] { display: none !important; }
.report .grid { margin: 10px 0; }
@media print {
  body * { visibility: hidden; }
  .report, .report * { visibility: visible; }
  .report { position: absolute; left: 0; top: 0; width: 100%; border: 0; background: #fff; color: #000; }
  .report .stat { background: #f2f2f2; }
  .report select, .report button, .report .banner { display: none !important; }
  .report .up { color: #0a7a35; } .report .down { color: #c0233b; } .report small, .report .muted { color: #444; }
}

/* owner 21 Nov: live price flash, loss-limit banner, notifications bell + panel */
.live { font-variant-numeric: tabular-nums; border-radius: 4px; padding: 0 3px; }
.tick-up { animation: tickUp 1.2s ease-out; } .tick-dn { animation: tickDn 1.2s ease-out; }
@keyframes tickUp { from { background: rgba(61, 220, 132, .45); } to { background: transparent; } }
@keyframes tickDn { from { background: rgba(255, 92, 122, .45); } to { background: transparent; } }
.banner.danger { border-color: var(--sell); color: #9B1C31; background: #FDE8EC; }
.bell { position: relative; background: var(--surface2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; color: var(--fg); }
.bell[hidden] { display: none; }
.bell .badge { position: absolute; top: -6px; right: -6px; background: var(--sell); color: #fff; font-size: .68rem; font-weight: 700; border-radius: 999px; padding: 1px 6px; }
.notice { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; gap: 4px; font-size: .88rem; }
.notice.new { border-left: 3px solid var(--warn); padding-left: 8px; }
.prodnote { margin: 0; font-size: .82rem; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }

/* NeoTrade 5 wordmark (no tagline) */
.brand .wm { font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.brand .wm span { background: var(--flame); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand img { border-radius: 10px; }

/* light theme touches */
.top { box-shadow: 0 1px 0 var(--line), 0 4px 14px rgba(28, 21, 48, .05); }
.card { box-shadow: 0 2px 10px rgba(28, 21, 48, .04); }
.sheet { box-shadow: 0 18px 50px rgba(28, 21, 48, .25); }
.toast { background: #1C1530; color: #fff; border-color: #1C1530; }
