:root {
  --bg: #eeeaf8;
  --card: #fbfaff;
  --ink: #1f1b3a;
  --muted: #6e6a8a;
  --line: #e2ddf3;
  --primary: #5b4fd6;
  --primary-2: #7c6ff0;
  --soft: #e8e3fb;
  --green: #12a150;
  --red: #d93a49;
  --blue: #2f7dd1;
  --amber: #c98a12;
  --field: #fff; --tab-bg: #f4f1fe; --slider-off: #cfc9e8; --code-bg: #f6f4ff; --info-1: #f3f0ff; --info-2: #fff;
  --green-soft: #dcf5e7; --red-soft: #fde2e5; --amber-soft: #fdf0d5; --amber-line: #f3dfb0; --amber-ink: #7a5a12;
  --badge-bg: #eee; --badge-ink: #555; --on-primary: #fff;
  --radius: 16px;
  --shadow: 0 6px 20px rgba(70, 55, 160, .10);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
#app { max-width: 520px; margin: 0 auto; padding: 12px 14px calc(28px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 19px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.err { color: var(--red); min-height: 18px; font-size: 13.5px; margin: 8px 0 0; }
.ok { color: var(--green); min-height: 18px; font-size: 13.5px; margin: 8px 0 0; }

/* hero / header */
.brand-hero { text-align: center; padding: 34px 0 18px; }
.hero-logo { width: 84px; height: 84px; border-radius: 22px; box-shadow: var(--shadow); }
.brand-hero h1 { margin-top: 12px; font-size: 26px; }
.brand-hero p { color: var(--muted); margin: 0; }
.top { display: flex; align-items: center; justify-content: space-between; padding: 6px 2px 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.brand img { width: 38px; height: 38px; border-radius: 11px; box-shadow: var(--shadow); }
.statusbar { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--soft); color: var(--primary); letter-spacing: .02em; }
.pill.ghost { background: var(--field); color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }

/* tabs */
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tabs button, .tabs span { border: 1px solid var(--line); background: var(--tab-bg); color: var(--ink); border-radius: 12px;
  padding: 9px 4px; font-size: 12.5px; font-weight: 600; text-align: center; cursor: pointer; }
.tabs button.active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); box-shadow: var(--shadow); }
.tabs.disabled span { opacity: .55; cursor: default; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px; }
label { display: block; font-size: 12.5px; color: var(--muted); margin: 12px 0 6px; font-weight: 600; }
.input { width: 100%; border: 1px solid var(--line); background: var(--field); border-radius: 12px; padding: 12px 13px;
  font-size: 15px; color: var(--ink); outline: none; }
.input:focus { border-color: var(--primary-2); box-shadow: 0 0 0 3px rgba(124, 111, 240, .18); }
textarea.input { resize: vertical; font-family: inherit; }
.pin { text-align: center; font-size: 22px; letter-spacing: .35em; margin-top: 10px; }
.pw { position: relative; }
.eye { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; font-size: 18px; cursor: pointer; }
.adv { margin-top: 10px; } .adv summary { color: var(--muted); font-size: 13px; cursor: pointer; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--field); font-size: 13px; font-weight: 600; }
.chip.on { border-color: var(--primary); background: var(--soft); color: var(--primary); }
.small-chips { margin-top: 12px; } .small-chips .pill { font-size: 11.5px; }

/* buttons */
.btn { border: 0; border-radius: 12px; padding: 12px 14px; font-size: 15px; font-weight: 700; cursor: pointer; }
.btn.full { width: 100%; margin-top: 14px; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: var(--on-primary); box-shadow: var(--shadow); }
.btn.danger { background: var(--red); color: #fff; } .btn.blue { background: var(--blue); color: #fff; }
.btn.ghost { background: var(--field); color: var(--ink); border: 1px solid var(--line); }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .6; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--tab-bg); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; padding: 10px 4px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--field); color: var(--primary); box-shadow: 0 2px 8px rgba(70, 55, 160, .15); }

/* switch */
.switch { position: relative; width: 58px; height: 32px; display: inline-block; }
.switch input { display: none; }
.slider { position: absolute; inset: 0; background: var(--slider-off); border-radius: 999px; transition: .2s; cursor: pointer; }
.slider::before { content: ""; position: absolute; width: 26px; height: 26px; left: 3px; top: 3px; background: #ffffff;
  border-radius: 50%; transition: .2s; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(26px); }

/* live */
.equity .big { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row3 div { display: flex; flex-direction: column; } .row3 b { font-size: 15px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; }
.tile span { font-size: 12px; color: var(--muted); font-weight: 600; } .tile b { font-size: 22px; margin-top: 2px; }
.tile small { color: var(--muted); font-size: 11.5px; }
.pos { color: var(--green); } .neg { color: var(--red); }
.bar-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin: 6px 0 5px; font-weight: 600; }
.bar { height: 9px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-bottom: 8px; }
.bar div { height: 100%; width: 0; background: var(--green); border-radius: 99px; transition: width .4s; }
.log { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; max-height: 260px; overflow: auto;
  background: var(--code-bg); border-radius: 10px; padding: 10px; white-space: pre-wrap; word-break: break-word; }
.list .item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 8px; }
.list .item:last-child { border-bottom: 0; }
.item .l { display: flex; flex-direction: column; } .item .l b { font-size: 14.5px; } .item .l small { color: var(--muted); font-size: 11.5px; }
.item .r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.side { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; margin-left: 6px; }
.side.BUY { background: var(--green-soft); color: var(--green); } .side.SELL { background: var(--red-soft); color: var(--red); }
.xbtn { border: 1px solid var(--line); background: var(--field); border-radius: 8px; padding: 4px 10px; font-size: 12px; font-weight: 700; cursor: pointer; }

/* strategy */
.info { background: linear-gradient(135deg, var(--info-1), var(--info-2)); }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.kpis div { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.kpis b { display: block; font-size: 20px; color: var(--primary); } .kpis span { font-size: 11.5px; color: var(--muted); }
.form h3 { margin-top: 18px; } .form h3:first-child { margin-top: 0; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; font-size: 13.5px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.badge { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--badge-bg); color: var(--badge-ink); white-space: nowrap; }
.badge.Active { background: var(--green-soft); color: var(--green); } .badge.Filtered { background: var(--red-soft); color: var(--red); }

/* toast & modal */
.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #221d45; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; max-width: 90%; box-shadow: var(--shadow); z-index: 20; }
.modal { position: fixed; inset: 0; background: rgba(20, 15, 50, .45); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 20px; }
.modal-card { background: var(--field); border-radius: 16px; padding: 18px; max-width: 360px; width: 100%; box-shadow: var(--shadow); }

.demo-note { background: var(--amber-soft); border-color: var(--amber-line); color: var(--amber-ink); font-size: 13px; }

/* ---------------- PipScalper themes ---------------- */
html[data-theme="midnight"] { --bg: #070b16; --card: #0f1626; --ink: #e9eefc; --muted: #8a96b8; --line: #1d2842;
  --primary: #10d39a; --primary-2: #19a7ff; --soft: #13213a; --green: #22d38a; --red: #ff5a6a; --blue: #3b9cff; --amber: #f5b638;
  --shadow: 0 8px 26px rgba(0, 0, 0, .45); --field: #0b1220; --tab-bg: #0b1220; --slider-off: #2a3654; --code-bg: #0a101d;
  --info-1: #10223c; --info-2: #0f1626; --green-soft: rgba(34, 211, 138, .14); --red-soft: rgba(255, 90, 106, .15);
  --amber-soft: rgba(245, 182, 56, .14); --amber-line: rgba(245, 182, 56, .35); --amber-ink: #f5c86a;
  --badge-bg: #1a2440; --badge-ink: #9fb0d6; --on-primary: #04121f; }
html[data-theme="gold"] { --bg: #0b0a08; --card: #16140f; --ink: #f6efe0; --muted: #a59a82; --line: #2c261b;
  --primary: #f5b301; --primary-2: #ffd75e; --soft: #241f14; --green: #3ddc84; --red: #ff5d5d; --blue: #5aa9ff; --amber: #f5b301;
  --shadow: 0 8px 26px rgba(0, 0, 0, .5); --field: #100e0b; --tab-bg: #100e0b; --slider-off: #3a3324; --code-bg: #0f0d0a;
  --info-1: #2a2212; --info-2: #16140f; --green-soft: rgba(61, 220, 132, .14); --red-soft: rgba(255, 93, 93, .15);
  --amber-soft: rgba(245, 179, 1, .14); --amber-line: rgba(245, 179, 1, .35); --amber-ink: #ffd75e;
  --badge-bg: #2a251b; --badge-ink: #cbbf9f; --on-primary: #1a1405; }
html[data-theme="light"] { --bg: #f3f6fb; --card: #ffffff; --ink: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --primary: #059669; --primary-2: #0ea5e9; --soft: #e6f6f1; --green: #059669; --red: #dc2626; --blue: #2563eb; --amber: #b45309;
  --shadow: 0 6px 20px rgba(15, 23, 42, .08); --field: #fff; --tab-bg: #eef2f7; --slider-off: #cbd5e1; --code-bg: #f1f5f9;
  --info-1: #e8f8f2; --info-2: #fff; --green-soft: #dcfce7; --red-soft: #fee2e2; --amber-soft: #fef3c7; --amber-line: #fde68a;
  --amber-ink: #92400e; --badge-bg: #eef2f7; --badge-ink: #475569; --on-primary: #fff; }
html[data-theme="midnight"] .pill, html[data-theme="gold"] .pill { background: var(--soft); }
.wm b { background: linear-gradient(135deg, var(--primary), var(--primary-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand .wm { letter-spacing: -.01em; }
.brand-hero h1.wm { font-size: 30px; font-weight: 800; }
.hero-logo { width: 96px; height: 96px; border-radius: 26px; box-shadow: 0 12px 34px rgba(16, 211, 154, .25); }
.themes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.themes button { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--field); color: var(--ink); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.themes button i { width: 22px; height: 22px; border-radius: 7px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .35); }
.themes button.active { border-color: var(--primary); box-shadow: inset 0 0 0 1.5px var(--primary); }
