:root {
  --bg: #0A1230; --surface: #131D45; --surface2: #1A2656; --line: #26336A; --fg: #fff; --muted: #A9B4D6;
  --accent: #00D4F5; --buy: #2F8CFF; --sell: #FF5C7A; --up: #3DDC84; --down: #FF5C7A; --warn: #FFC24B;
  color-scheme: dark;
}
* { 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: var(--surface2); border: 1px solid var(--warn); color: var(--warn); 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; }

.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, 194, 75, .06); }
.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(0, 0, 0, .55); 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 { 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(--accent); color: #04122e; 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; }

.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; }
}
