:root {
  --bg: #0f1a26;
  --surface: #172433;
  --surface-2: #1e2e40;
  --border: #2c4157;
  --text: #eef3f8;
  --muted: #93a6ba;
  --gold: #e3b54a;            /* brand accent (set per brand from /api/config) */
  --accent-hi: #f2cd6b;
  --accent-lo: #d6a33a;
  --gold-ink: #241a03;
  --buy: #3ccf7a;
  --sell: #f0594f;
  --error: #ff8a80;
  --focus: #ffd56b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom));
}

.brand { display: flex; align-items: center; gap: 12px; margin-block-end: 20px; }
.brand-mark {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 12px;
  background: linear-gradient(145deg, var(--accent-hi), var(--accent-lo));
  color: var(--gold-ink); font-weight: 800; letter-spacing: .02em;
}
.brand-name { margin: 0; font-weight: 800; letter-spacing: .06em; color: var(--gold); }
.brand-sub { margin: 0; font-size: .875rem; color: var(--muted); }

form { display: grid; gap: 18px; }

fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: grid; gap: 6px; }
label, legend { font-weight: 600; font-size: .9375rem; }
legend { padding: 0; margin-block-end: 6px; }
.sub-label { display: block; font-weight: 500; font-size: .8125rem; color: var(--muted); margin-block-end: 4px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

input[type="text"], select {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font-size: 1.0625rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-inline-end: 40px;
  font-weight: 700;
}
input::placeholder { color: #5d7186; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible,
.segmented input:focus-visible + label {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}
input[aria-invalid="true"] { border-color: var(--error); }

.hint { margin: 0; font-size: .8125rem; color: var(--muted); }
.error { margin: 0; font-size: .8125rem; color: var(--error); }
.error:empty { display: none; }

.auto {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.auto-head { display: flex; align-items: center; justify-content: space-between; margin-block-end: 10px; }
h2 { margin: 0; font-size: .9375rem; }
.section-title { margin-block-end: 8px; }

.badge {
  font-size: .8125rem; font-weight: 800; letter-spacing: .06em;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.badge[data-side="BUY"] { background: color-mix(in srgb, var(--buy) 18%, transparent); color: var(--buy); }
.badge[data-side="SELL"] { background: color-mix(in srgb, var(--sell) 18%, transparent); color: var(--sell); }

.tp-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tp-list li {
  background: var(--surface-2); border-radius: 10px; padding: 8px 10px;
  display: grid; gap: 2px;
}
.tp-list span { font-size: .75rem; color: var(--muted); font-weight: 600; }
.tp-list strong { font-variant-numeric: tabular-nums; font-size: 1rem; overflow-wrap: anywhere; }
.tp-list li:last-child strong { color: var(--gold); }

.bubble {
  background: #1d2b3a;
  border-radius: 14px 14px 14px 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
}
.preview {
  margin: 0;
  white-space: pre-wrap;
  font: inherit;
  font-size: .9375rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.segmented {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 4px; gap: 4px;
}
.segmented input { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; margin: -1px; }
.segmented label {
  display: grid; place-items: center; min-height: 44px; border-radius: 9px;
  font-size: .875rem; color: var(--muted); cursor: pointer; text-align: center; padding: 0 6px;
}
.segmented input:checked + label { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--gold); }

.status { margin: 0; font-size: .875rem; color: var(--error); }
.status:empty { display: none; }

.actions { position: sticky; bottom: 0; padding-block: 8px calc(8px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 30%); }

.primary, .secondary {
  display: grid; place-items: center;
  width: 100%; min-height: 52px;
  border-radius: 12px; border: 0;
  font: inherit; font-weight: 800; font-size: 1rem; letter-spacing: .02em;
  cursor: pointer; text-decoration: none;
}
.primary { background: linear-gradient(180deg, var(--accent-hi), var(--accent-lo)); color: var(--gold-ink); }
.primary:disabled { opacity: .6; cursor: progress; }
.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }

.done { text-align: center; display: grid; gap: 12px; padding-block-start: 40px; }
.done[hidden], .done a[hidden], .done p[hidden] { display: none; }
.done #done-voucher strong { color: var(--text); letter-spacing: .06em; }
.done h2 { font-size: 1.25rem; }
.done p { margin: 0; color: var(--muted); }
.done-icon {
  justify-self: center; display: grid; place-items: center;
  width: 64px; height: 64px; border-radius: 50%;
  background: color-mix(in srgb, var(--buy) 20%, transparent); color: var(--buy);
  font-size: 2rem; font-weight: 800;
}

/* Support & resistance */
.sr { display: grid; gap: 12px; }
.sr .auto-head { margin-block-end: 0; }
.source { font-size: .75rem; font-weight: 700; color: var(--muted); }
.source[data-ai="true"] { color: var(--gold); }

.ai-controls { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: stretch; }
.ai-controls[hidden] { display: none; }
.segmented.tf { grid-template-columns: repeat(4, 1fr); background: var(--surface-2); }
.segmented.tf label { min-height: 40px; }
.ai-btn {
  min-height: 48px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--gold); background: color-mix(in srgb, var(--gold) 14%, transparent);
  color: var(--gold); font: inherit; font-weight: 800; cursor: pointer; white-space: nowrap;
}
.ai-btn:disabled { opacity: .6; cursor: progress; }

.chart-wrap { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
.chart-wrap[hidden] { display: none; }
.chart-wrap canvas { display: block; width: 100%; height: auto; }
.chart-wrap.loading { opacity: .5; }

.ai-note { margin: 0; font-size: .875rem; color: var(--muted); }
.ai-note::before { content: "🤖 "; }
.ai-note[hidden] { display: none; }

.level-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.level-list:empty { display: none; }
.level {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
}
.level-tag {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px;
  font-weight: 800; font-size: .875rem;
}
.level[data-type="support"] .level-tag { background: color-mix(in srgb, var(--buy) 18%, transparent); color: var(--buy); }
.level[data-type="resistance"] .level-tag { background: color-mix(in srgb, var(--sell) 18%, transparent); color: var(--sell); }
.level input[type="text"] { min-height: 44px; padding: 8px 12px; background: var(--surface-2); }
.level-remove {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font-size: 1.25rem; cursor: pointer;
}
.level-add { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chip {
  min-height: 44px; border-radius: 10px; border: 1px dashed var(--border);
  background: transparent; color: var(--text); font: inherit; font-size: .875rem; font-weight: 600; cursor: pointer;
}
.field[hidden] { display: none; }

/* Google login */
.checking { margin: 40px 0; text-align: center; color: var(--muted); }
.checking[hidden], .account[hidden], .gate[hidden], form[hidden] { display: none; }
.account {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: -8px 0 16px; padding: 8px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: .8125rem; color: var(--muted);
}
.account strong { color: var(--text); font-weight: 600; overflow-wrap: anywhere; }
.link-btn {
  min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--gold); font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.gate { text-align: center; display: grid; gap: 14px; padding-block-start: 32px; }
.gate h1 { margin: 0; font-size: 1.25rem; }
.gate p { margin: 0; color: var(--muted); }
.gate-icon {
  justify-self: center; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: color-mix(in srgb, var(--gold) 16%, transparent); font-size: 1.75rem;
}
.gate-status { font-size: .875rem; }
.gate-status:empty { display: none; }
.gate-status[data-error="true"] { color: var(--error); }
.segmented input:disabled + label { opacity: .4; cursor: not-allowed; }

/* Tabs: Signal / Sapaan */
.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-block-end: 18px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.tabs[hidden] { display: none; }
.tabs [role="tab"] {
  min-height: 44px; border: 0; border-radius: 9px; background: transparent;
  color: var(--muted); font: inherit; font-weight: 700; cursor: pointer;
}
.tabs [role="tab"][aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--gold); }

/* SL mode */
.sl-panel { display: grid; gap: 6px; margin-block-start: 10px; }
.sl-panel[hidden] { display: none; }
.segmented.side input:checked + label[for="side-buy"] { box-shadow: inset 0 0 0 1px var(--buy); color: var(--buy); }
.segmented.side input:checked + label[for="side-sell"] { box-shadow: inset 0 0 0 1px var(--sell); color: var(--sell); }
#sl-auto-hint { font-size: .875rem; color: var(--text); }

/* Greeting */
.segmented.four { grid-template-columns: repeat(4, 1fr); }
textarea {
  width: 100%; min-height: 180px; padding: 12px 14px; resize: vertical;
  font: inherit; font-size: 1rem; line-height: 1.5; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
textarea[aria-invalid="true"] { border-color: var(--error); }

/* Entry area mode */
.area-mode { margin-block-end: 10px; }
#entry-row.single { grid-template-columns: 1fr; }
#entry-row.single > div:nth-child(2) { display: none; }
.area-hint { font-size: .875rem; color: var(--text); }
.area-hint[hidden] { display: none; }
.tp-rule { margin-block-start: 10px; }

/* TP mode */
.tp-mode { margin-block-end: 12px; background: var(--surface-2); }
.tp-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tp-inputs[hidden], #tp-auto[hidden] { display: none; }
.tp-inputs input[type="text"] { padding: 10px; background: var(--surface-2); }

/* Recap */
.tabs { grid-template-columns: repeat(3, 1fr); }
.visually-hidden { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; margin: -1px; white-space: nowrap; }
input[type="date"], input[type="month"] {
  width: 100%; min-height: 50px; padding: 12px 14px; font: inherit; font-size: 1.0625rem;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  color-scheme: dark;
}
.recap-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0; }
.recap-summary div { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; display: grid; gap: 2px; }
.recap-summary dt { font-size: .75rem; color: var(--muted); font-weight: 600; }
.recap-summary dd { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.recap-summary .pos { color: var(--buy); }
.recap-summary .neg { color: var(--sell); }
.recap-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.recap-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; align-items: center;
}
.recap-item .title { font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.recap-item .meta { grid-column: 1 / -1; font-size: .75rem; color: var(--muted); }
.recap-item .result { font-size: .9375rem; }
.recap-item select { min-height: 40px; padding: 6px 30px 6px 10px; font-size: .875rem; font-weight: 600; background-position: calc(100% - 16px) 50%, calc(100% - 10px) 50%; }
.recap-item[data-admin="true"] select { box-shadow: inset 0 0 0 1px var(--gold); }

/* Recap: manual entry + delete */
.recap-add {
  background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; padding: 12px;
}
.recap-add[open] { display: grid; gap: 6px; border-style: solid; }
.recap-add summary { cursor: pointer; font-weight: 700; color: var(--gold); min-height: 32px; display: flex; align-items: center; }
.recap-add input[type="date"], .recap-add input[type="time"] {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; color-scheme: dark;
}
.recap-add input[type="text"], .recap-add select { background: var(--surface-2); }
.recap-add .secondary { margin-block-start: 6px; }
.recap-item .del {
  justify-self: end; min-height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); font: inherit; font-size: .8125rem; cursor: pointer;
}
.status[data-ok="true"] { color: var(--buy); }

/* Sapaan: AI news picture */
.news { display: grid; gap: 10px; }
.news[hidden] { display: none; }
.news .auto-head { margin-block-end: 0; }
.news .ai-btn { width: 100%; }

/* Brand header stays hidden until the brand is known, so a partner app never flashes the SOBAT FX name. */
.brand { visibility: hidden; }
.brand[data-ready] { visibility: visible; }
.dev-badge {
  margin-inline-start: 6px; padding: 1px 6px; border-radius: 6px; font-size: .6875rem; font-weight: 800;
  background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold);
}
.account { flex-wrap: wrap; }
.brand-switch {
  min-height: 34px; width: auto; padding: 4px 28px 4px 10px; font-size: .8125rem; font-weight: 700;
  background-color: var(--surface-2); border-radius: 8px; background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
}
.brand-switch[hidden] { display: none; }

/* SNR tab */
.tabs { grid-template-columns: repeat(4, 1fr); }
.tabs [role="tab"] { font-size: .875rem; padding: 0 2px; }
/* Lines are dragged on the chart, so touches there don't scroll the page. */
.snr-wrap canvas { touch-action: none; cursor: crosshair; }
.snr-list .level { grid-template-columns: auto 1fr auto auto; }
.snr-list .level-tag { width: auto; min-width: 36px; padding: 0 6px; font-size: .75rem; }
.snr-list select { width: auto; min-height: 44px; padding: 6px 30px 6px 10px; font-size: .8125rem; background-color: var(--surface-2); background-position: calc(100% - 16px) 50%, calc(100% - 10px) 50%; }
.snr-list .level[data-fresh="false"] input { color: var(--muted); }
#snr-hint[hidden], #snr-draw-hint[hidden], #snr-clear[hidden] { display: none; }

/* Zoom out (small timeframes) */
.zoom { display: grid; gap: 4px; }
.zoom[hidden] { display: none; }
.zoom legend { margin: 0 0 2px; }
.segmented.three { grid-template-columns: repeat(3, 1fr); background: var(--surface-2); }
.segmented.three label { min-height: 40px; line-height: 1.2; }
.segmented.three label small { display: block; font-size: .6875rem; color: var(--muted); font-weight: 500; }

/* M30: five timeframes, the button goes under them */
.segmented.tf { grid-template-columns: repeat(5, 1fr); }
.ai-controls { grid-template-columns: 1fr; }

/* SNR: FVG zones */
.fvg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fvg-list:empty { display: none; }
.fvg {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  padding: 6px 6px 6px 12px; border-radius: 10px; font-size: .875rem; font-variant-numeric: tabular-nums;
}
.fvg[data-type="sell"] { background: color-mix(in srgb, var(--sell) 14%, transparent); color: var(--sell); }
.fvg[data-type="buy"] { background: color-mix(in srgb, var(--buy) 14%, transparent); color: var(--buy); }
.fvg strong { font-weight: 800; margin-inline-end: 6px; }
.fvg .level-remove { width: 36px; height: 36px; }

/* Developer: bot check */
.bot-check { display: grid; gap: 10px; margin-block-end: 16px; }
.bot-check[hidden] { display: none; }
.bot-check .auto-head { margin-block-end: 0; }
.bot-check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.bot-check-list li { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: grid; gap: 4px; font-size: .8125rem; }
.bot-check-list strong { font-size: .9375rem; }
.bot-check-list .ok { color: var(--buy); }
.bot-check-list .bad { color: var(--error); }
.bot-check-list .meta { color: var(--muted); overflow-wrap: anywhere; }
#bot-check-open[hidden] { display: none; }
.segmented.tf.six { grid-template-columns: repeat(6, 1fr); }
.segmented.tf.six label { padding: 0 2px; font-size: .8125rem; }

/* SNR: Auto SNR / Input manual */
#snr-section[data-mode="manual"] .snr-auto-only,
#snr-section[data-mode="auto"] .snr-manual-only { display: none !important; }
.snr-manual { display: grid; gap: 8px; }
.zone-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.zone-rows:empty { display: none; }
.zone-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 5px; align-items: center; }
.zone-row .zone-n { font-size: .6875rem; font-weight: 800; color: var(--muted); min-width: 40px; }
.zone-row .zone-pips {
  width: auto; min-height: 44px; padding: 6px 22px 6px 8px; font-size: .8125rem; background-color: var(--surface-2);
  background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; background-size: 5px 5px;
}
.zone-row .zone-pips:disabled { opacity: .4; }
.zone-row .level-remove { width: 40px; height: 40px; }
.zone-row input[type="text"] { min-height: 44px; padding: 8px 10px; background: var(--surface-2); }
.zone-row .zone-dash { color: var(--muted); }
.zone-row[data-type="resistance"] .zone-n { color: var(--sell); }
.zone-row[data-type="support"] .zone-n { color: var(--buy); }
.segmented.method { grid-template-columns: repeat(3, 1fr); }
