/* Hotkey Trader phone remote: the side panel's theme and pad, sized for touch (iPad first, iPhone too). */
:root {
  --bg: #0a0f16; --card: rgba(16, 23, 33, .92); --card-line: #1f2b3a; --line: #263243;
  --text: #e8edf4; --muted: #8a96a8; --green: #2bd47c; --red: #ff5a63; --blue: #3d8bff; --yellow: #ffc928; --orange: #ffb04d;
  --gap: 8px; --key-h: 80px; --key-big: 106px; --key-small: 66px; --key-tiny: 54px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text);
  background: radial-gradient(120% 60% at 0% 0%, rgba(40, 90, 160, .16), transparent 60%), radial-gradient(100% 50% at 100% 100%, rgba(20, 120, 90, .08), transparent 60%), var(--bg);
  background-attachment: fixed;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; background: #0c121a; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; touch-action: none; }
input { font: inherit; }
[hidden] { display: none !important; }
/* icon sprite: no inline styles anywhere (CSP style-src 'self' blocks them) */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---- shell ---- */
.app, .pair { min-height: 100%; display: flex; flex-direction: column; padding: calc(var(--sat) + 10px) calc(var(--sar) + 14px) calc(var(--sab) + 6px) calc(var(--sal) + 14px); gap: var(--gap); }
.top { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 8px; }
.logo { width: 30px; height: 30px; stroke: none; fill: var(--blue); filter: drop-shadow(0 0 6px rgba(61, 139, 255, .55)); }
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 800; font-style: italic; letter-spacing: -.01em; line-height: 1.05; white-space: nowrap; }
.brand-text h1 span { color: var(--blue); }
.brand-text small { display: block; color: var(--muted); font-size: 9px; letter-spacing: .28em; text-transform: uppercase; margin-top: 2px; }
.chips { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 15px; font-weight: 700; font-size: 12.5px; white-space: nowrap; border: 1px solid var(--line); background: var(--card); }
.chip:empty { display: none; }
.chip.env { background: rgba(61, 139, 255, .15); border-color: rgba(61, 139, 255, .55); color: #8ab8ff; text-transform: uppercase; letter-spacing: .04em; }
.chip.env.live { background: rgba(255, 90, 99, .2); border-color: var(--red); color: #ff8a90; }
.chip.muted { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.chip.conn.ok { color: var(--green); border-color: rgba(43, 212, 124, .45); }
.chip.conn.ok .dot { background: var(--green); box-shadow: 0 0 8px rgba(43, 212, 124, .8); }
.chip.conn.warn { color: var(--yellow); border-color: rgba(255, 201, 40, .45); }
.chip.conn.warn .dot { background: var(--yellow); }
.chip.conn.bad { color: var(--red); border-color: rgba(255, 90, 99, .45); }
.chip.conn.bad .dot { background: var(--red); }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--card); }
.icon-btn svg { width: 20px; height: 20px; }
.preview-badge { align-self: center; margin: -4px 0; font-size: 12px; font-weight: 700; color: #1a1300; background: var(--yellow); padding: 4px 12px; border-radius: 12px; }

.layout { flex: 1; display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-content: start; }
.side { display: grid; gap: var(--gap); align-content: start; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.side > .status, .side > .result, .side > .bo-card { grid-column: 1 / -1; }
.card { border: 1px solid var(--card-line); background: var(--card); border-radius: 14px; padding: 8px 14px; }

/* ---- live state ---- */
.status { display: grid; gap: 8px; }
.st-row { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; }
.st span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.st b { display: block; font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st b.pos-long { color: var(--green); } .st b.pos-short { color: var(--red); }
.up { color: var(--green) !important; } .down { color: var(--red) !important; }
.warn { margin: 0; padding: 7px 10px; border-radius: 9px; background: rgba(255, 201, 40, .12); border: 1px solid rgba(255, 201, 40, .4); color: var(--yellow); font-weight: 600; font-size: 13px; }
.warn.bad { background: rgba(255, 90, 99, .12); border-color: rgba(255, 90, 99, .45); color: #ff8a90; }

.pickers { grid-column: 1 / -1; display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.pick { display: grid; grid-template-columns: auto 52px minmax(0, 1fr) 52px; align-items: center; gap: 8px; }
.pick .lab { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.pick .val { text-align: center; font-size: 17px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step { height: 48px; min-width: 52px; display: grid; place-items: center; font-size: 24px; font-weight: 700; background: #0c121a; border-radius: 12px; }
.step svg { width: 22px; height: 22px; }
.step:active { background: #16202c; border-color: var(--blue); }

/* ---- arm ---- */
.arm { grid-column: 1 / -1; position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 0 18px; border-radius: 14px; border: 1px solid #3a4a60; background: linear-gradient(180deg, #172131, #0e1520); font-size: 18px; font-weight: 800; }
.arm .arm-fill { position: absolute; inset: 0; width: 0; background: linear-gradient(90deg, rgba(43, 212, 124, .25), rgba(43, 212, 124, .55)); }
.arm.holding .arm-fill { width: 100%; transition: width .6s linear; }
.arm > :not(.arm-fill) { position: relative; }
.arm .lock { width: 26px; height: 26px; }
.arm-hint { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--muted); }
.arm[aria-pressed="true"] { border-color: var(--green); background: linear-gradient(180deg, #13693f, #0b4128); box-shadow: 0 0 18px rgba(43, 212, 124, .35); }
.arm[aria-pressed="true"] .arm-hint { color: #c9f5dc; }
.arm.waiting { border-color: var(--yellow); }
.arm:disabled { opacity: .55; }

/* ---- results ---- */
.result { display: grid; gap: 6px; }
.r-main { font-size: 16px; font-weight: 700; min-height: 22px; }
.r-main.ok { color: var(--green); } .r-main.err { color: #ff8a90; } .r-main.wait { color: var(--yellow); }
.r-list { list-style: none; margin: 0; padding: 0; display: block; font-size: 12.5px; line-height: 18px; color: var(--muted); max-height: 36px; overflow: hidden; }
.r-list:empty { display: none; }
.r-list li { display: flex; gap: 8px; height: 18px; white-space: nowrap; overflow: hidden; }
.r-list li .t { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.r-list li .x { overflow: hidden; text-overflow: ellipsis; }
.r-list li.ok .k { color: var(--green); } .r-list li.err .k { color: var(--red); }
.bo-card { border-color: rgba(255, 176, 77, .5); }
.bo-head { display: flex; align-items: center; gap: 10px; }
.bo-head b { color: var(--orange); }
.mini { margin-left: auto; height: 40px; padding: 0 14px; font-weight: 700; }
.bo-list { font-variant-numeric: tabular-nums; color: var(--text); font-size: 14px; margin-top: 4px; }

/* ---- the pad (mirrors the side panel) ---- */
.pad { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-content: start; }
.key {
  --c1: #1b2430; --c2: #121922; --edge: #2c394a; --glow: transparent;
  position: relative; grid-column: span 3; min-height: var(--key-h); padding: 8px 6px; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: linear-gradient(180deg, var(--c1), var(--c2)); border: 1px solid var(--edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), inset 0 -2px 0 rgba(0, 0, 0, .25), 0 0 14px var(--glow), 0 4px 0 #05080c;
  color: #e9eef5; text-align: center; transition: transform .05s, filter .1s, opacity .15s;
}
.key.pressed { transform: translateY(3px); filter: brightness(1.18); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 0 18px var(--glow), 0 1px 0 #05080c; }
.key svg { width: 26px; height: 26px; stroke-width: 2.2; }
.key b { font-size: 17px; font-weight: 800; line-height: 1.12; letter-spacing: .02em; }
.key em { font-style: normal; }
.key small { font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, .78); font-variant-numeric: tabular-nums; }
.key small:empty { display: none; }
.key.big { grid-column: span 6; min-height: var(--key-big); }
.key.big b { font-size: 22px; }
.key.big svg { width: 32px; height: 32px; }
.key.buy-bid, .key.sell-ask { grid-column: span 6; }
.key.buy { --c1: #1f9d5a; --c2: #0c5a33; --edge: #2bd47c; --glow: rgba(43, 212, 124, .22); }
.key.sell { --c1: #d23a43; --c2: #7c1820; --edge: #ff5a63; --glow: rgba(255, 90, 99, .22); }
.key.buy-bid { --c1: #12804a; --c2: #08472a; --edge: #22b86a; --glow: rgba(34, 184, 106, .18); }
.key.sell-ask { --c1: #a92a35; --c2: #5f121b; --edge: #e2464f; --glow: rgba(226, 70, 79, .18); }
.key.buy-lim { --c1: #2bc76c; --c2: #137a3e; --edge: #4ff09a; --glow: rgba(79, 240, 154, .25); }
.key.sell-lim { --c1: #ec4650; --c2: #9b1d27; --edge: #ff7078; --glow: rgba(255, 112, 120, .25); }
.key.close { --c1: #ffd84d; --c2: #f0aa00; --edge: #ffe27a; --glow: rgba(255, 201, 40, .35); grid-column: 1 / -1; min-height: 76px; color: #1a1300; flex-direction: row; gap: 12px; }
.key.close b { font-size: 21px; letter-spacing: .03em; }
.key.close svg { width: 30px; height: 30px; }
.key.blue { --c1: #2f80ff; --c2: #1447c4; --edge: #5a9cff; --glow: rgba(61, 139, 255, .3); }
.key.breakout { --c1: #e8891c; --c2: #8f4a07; --edge: #ffb04d; --glow: rgba(255, 176, 77, .28); }
.key.red-text b { color: #ff9196; }
.key.small { min-height: var(--key-small); flex-direction: row; gap: 10px; }
.key.small b { font-size: 14px; text-align: left; }
.key.wide { grid-column: span 6; min-height: var(--key-tiny); }
.key.tiny { grid-column: span 3; min-height: var(--key-tiny); flex-direction: row; gap: 8px; }
.key.tiny b { font-size: 14px; }
.key.tiny svg { width: 20px; height: 20px; }
.key.ok { outline: 3px solid var(--green); outline-offset: 2px; }
.key.err { outline: 3px solid var(--red); outline-offset: 2px; }
.key.sending { outline: 3px dashed var(--yellow); outline-offset: 2px; }

.lim-adj { grid-column: span 6; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); padding: 8px; }
.bo-adj { grid-column: span 6; }
.lim-title { color: #b4bfcd; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper b { min-width: 64px; text-align: center; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.mod { grid-column: 1 / -1; display: grid; grid-template-columns: auto repeat(2, minmax(0, 1fr)) auto repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: center; }
.mod .key.tiny { grid-column: auto; }
.mod-lab { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 0 2px; }

/* Locked (disarmed / offline): exits stay visibly the same colour family but everything is dimmed. */
body.locked .pad .key, body.locked .pad .step, body.locked .pickers .step { opacity: .38; filter: saturate(.45); }
body.locked .pad::after { content: none; }

/* ---- flash (iPhone has no vibration: colour + optional sound) ---- */
.flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s; box-shadow: inset 0 0 0 10px var(--green); }
.flash.ok { box-shadow: inset 0 0 0 10px var(--green), inset 0 0 120px rgba(43, 212, 124, .35); }
.flash.err { box-shadow: inset 0 0 0 10px var(--red), inset 0 0 120px rgba(255, 90, 99, .35); }
.flash.on { opacity: 1; transition: none; }

/* ---- QTP credit (variant A, as in the extension) ---- */
.qtp-foot { display: flex; align-items: center; gap: 12px; padding: 4px 2px; min-height: 24px; font-size: 11.5px; color: var(--muted); opacity: .72; }
.qtp-foot a { color: inherit; text-decoration: none; }
.qtp-credit { display: inline-flex; align-items: center; gap: 6px; }
.qtp-credit img { width: 13px; height: 13px; display: block; }
.foot-note { margin-left: auto; text-align: right; }

/* ---- pairing ---- */
.pair { align-items: center; justify-content: center; }
.pair-card { width: min(520px, 100%); border: 1px solid var(--card-line); background: var(--card); border-radius: 18px; padding: 24px; display: grid; gap: 12px; }
.pair-card h2 { margin: 6px 0 0; font-size: 22px; }
.pair-card p { margin: 0; color: #c3ccd8; }
form { display: grid; gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
label.row { display: flex; align-items: center; gap: 10px; text-transform: none; font-size: 15px; color: var(--text); letter-spacing: 0; }
label.row input { width: 24px; height: 24px; }
input:not([type]) { height: 54px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #0c121a; color: var(--text); font-size: 22px; font-weight: 700; letter-spacing: .12em; -webkit-user-select: text; user-select: text; }
#pair-name { font-size: 17px; letter-spacing: 0; font-weight: 600; }
.primary { height: 54px; border-color: var(--blue); background: linear-gradient(180deg, #2f80ff, #1447c4); font-weight: 800; font-size: 17px; touch-action: manipulation; }
.danger { height: 48px; border-color: rgba(255, 90, 99, .6); color: #ff8a90; font-weight: 700; padding: 0 16px; touch-action: manipulation; }
.msg { min-height: 20px; font-weight: 600; }
.msg.err { color: #ff8a90; } .msg.ok { color: var(--green); }
.fine { font-size: 12.5px; color: var(--muted) !important; }

.menu { width: min(460px, 92vw); border: 1px solid var(--line); background: #0d141d; color: var(--text); border-radius: 18px; padding: 20px; }
.menu::backdrop { background: rgba(0, 0, 0, .55); }
.menu h3 { margin: 0 0 6px; }
.m-lat { display: grid; gap: 6px; margin: 14px 0; }
.m-lat div { display: flex; justify-content: space-between; }
.m-lat span { color: var(--muted); }
.m-btns { display: flex; gap: 10px; justify-content: space-between; margin-top: 10px; }
.m-btns .primary { padding: 0 26px; height: 48px; }

/* ---- landscape iPad: state on the left, pad on the right ---- */
@media (orientation: landscape) and (min-width: 900px) {
  :root { --key-h: 94px; --key-big: 124px; --key-small: 80px; --key-tiny: 56px; }
  .layout { grid-template-columns: minmax(330px, 36%) minmax(0, 1fr); grid-template-areas: "side pad" "extra pad"; grid-template-rows: auto 1fr; }
  .side { grid-area: side; } .pad { grid-area: pad; } .pad2 { grid-area: extra; align-self: end; }
  .r-list { max-height: 108px; }
  .side { grid-template-columns: minmax(0, 1fr); }
  .pickers { grid-template-columns: 1fr; gap: 10px; }
  .st-row { grid-template-columns: 1fr 1fr 1fr; }
  .st b { font-size: 16px; }
}
/* phones */
@media (max-width: 600px) {
  :root { --gap: 7px; --key-h: 70px; --key-big: 92px; --key-small: 58px; }
  .app { padding-left: calc(var(--sal) + 8px); padding-right: calc(var(--sar) + 8px); }
  .brand-text h1 { font-size: 16px; }
  .brand-text small { display: none; }
  #rtt { display: none; }
  .chip { height: 28px; padding: 0 9px; font-size: 11.5px; }
  .st b { font-size: 15px; }
  .pickers { grid-template-columns: 1fr; gap: 8px; }
  .pick { grid-template-columns: 80px 46px minmax(0, 1fr) 46px; }
  .step { height: 46px; min-width: 46px; }
  .key b { font-size: 13.5px; }
  .key.big b { font-size: 17px; }
  .key.close b { font-size: 16px; }
  .key.small { flex-direction: column; gap: 3px; }
  .key.small b { font-size: 11px; text-align: center; }
  .key svg { width: 20px; height: 20px; }
  .key.tiny b { font-size: 11.5px; }
  .stepper b { font-size: 18px; min-width: 48px; }
  .foot-note { display: none; }
}
@media (orientation: portrait) and (min-height: 1300px) {
  :root { --key-h: 96px; --key-big: 132px; --key-small: 80px; --key-tiny: 64px; --gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { .arm.holding .arm-fill { transition: none; } }
