/* Trigger Algo Mobile — design tokens and structural classes, ported from the
   reference design (Trigger Algo Mobile.dc.html). Mono palette: red is risk
   and loss only. No icons — state is carried by tags, rules and numerals. */

:root {
  color-scheme: light;
  --ink: #201e1d;
  --red: #ec3013;
  --red7: #ae1800;
  --red-light: #ffe0d9;
  --sub: #605d5d;
  --line: #d7d3d3;
  --line-strong: #bab6b6;
  --bg: #e6e4e3;
  --panel: #f3f2f2;
  --header: #eae9e9;
  --box: #f8f4f4;
  --chart-wash: rgba(32, 30, 29, 0.07);
  --ink-hover: #383533;
  /* A solid danger plate (EXIT/KILL buttons, EXIT/TOUCHED tag fills) reads
     fine as a dark red rectangle with light text regardless of page theme,
     so it and its paired text stay constant -- only --red7 (used as
     FOREGROUND text directly on the page background) needs to flip for
     contrast. Deliberately outside the dark-mode blocks below. */
  --danger-fill: #ae1800;
  --danger-fill-hover: #7c1405;
  --on-danger: #fff;
}

/* Dark palette: same mono-plus-red language, luminance inverted. --red7 is
   brightened (it is used as FOREGROUND text — "WATCHING", losses — where the
   light palette's dark brick-red would fail contrast on a dark background;
   --red stays vivid enough as-is for both). System preference is the default;
   an explicit [data-theme] always wins over it in both directions. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #f3f2f2;
    --red: #ff5a3c;
    --red7: #ff8a68;
    --red-light: #3a1f19;
    --sub: #9a9694;
    --line: #3a3735;
    --line-strong: #4d4946;
    --bg: #121110;
    --panel: #1c1a19;
    --header: #242220;
    --box: #262422;
    --chart-wash: rgba(243, 242, 241, 0.08);
    --ink-hover: #d8d6d4;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #f3f2f2;
  --red: #ff5a3c;
  --red7: #ff8a68;
  --red-light: #3a1f19;
  --sub: #9a9694;
  --line: #3a3735;
  --line-strong: #4d4946;
  --bg: #121110;
  --panel: #1c1a19;
  --header: #242220;
  --ink-hover: #d8d6d4;
  --box: #262422;
  --chart-wash: rgba(243, 242, 241, 0.08);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  font-family: 'Archivo', system-ui, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
input:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: 2px; }

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  background: var(--panel);
  position: relative;
  overflow: hidden;
}

/* -- header ------------------------------------------------------------- */

.app-header {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 12px 16px 10px;
  border-bottom: 2px solid var(--ink);
}
.app-header .brand { font-size: 15px; font-weight: 800; letter-spacing: -0.3px; }
.app-header .clock {
  margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: 0.8px;
  font-variant-numeric: tabular-nums; color: var(--sub);
}

.stat-row {
  flex: none; display: grid; grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 2px solid var(--ink); background: var(--header);
}
.stat-row > div { padding: 7px 12px; border-right: 1px solid var(--line-strong); }
.stat-row > div:last-child { border-right: none; }
.stat-row .k { font-size: 10px; font-weight: 700; letter-spacing: 1.1px; color: var(--sub); }
.stat-row .v { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.strip {
  flex: none; display: grid; grid-template-columns: 1fr 1fr 1fr;
  border-bottom: 2px solid var(--ink);
}
.strip button {
  padding: 10px 11px; border: 0; border-right: 1px solid var(--line-strong);
  text-align: left; background: var(--header); color: var(--sub);
}
.strip button.is-sel { background: var(--panel); color: var(--ink); box-shadow: inset 0 -4px 0 var(--red); }
.strip .row { display: flex; align-items: center; gap: 5px; }
.strip .sym { font-size: 11px; font-weight: 800; letter-spacing: 0.2px; }
.strip .dot { width: 7px; height: 7px; flex: none; }
.strip .spot { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.4px; margin-top: 2px; }
.strip .st { font-size: 10.5px; font-weight: 700; letter-spacing: 0.7px; margin-top: 1px; color: var(--sub); }

/* -- screen body ---------------------------------------------------------*/

.screen { flex: 1; min-height: 0; overflow: auto; }
.section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.section--thick { border-bottom: 2px solid var(--ink); }
.section--tight { padding-bottom: 6px; }

.kicker { font-size: 10.5px; font-weight: 700; letter-spacing: 1.4px; }
.kicker.sub { color: var(--sub); }
.note { margin: 9px 0 0; font-size: 11px; line-height: 1.5; color: var(--sub); }
.rule { height: 2px; background: var(--ink); margin: 0 0 12px; }
.rule--thin { height: 1px; background: var(--line); }

.big-num { font-weight: 800; letter-spacing: -2px; line-height: 0.9; font-variant-numeric: tabular-nums; }

.stat-grid { display: grid; gap: 1px; background: var(--line-strong); }
.stat-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.stat-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.stat-grid .cell { background: var(--panel); padding: 8px 10px 7px; }
.stat-grid .cell .k { font-size: 10px; font-weight: 700; letter-spacing: 1.1px; color: var(--sub); }
.stat-grid .cell .v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }

/* -- buttons -------------------------------------------------------------*/

.btn {
  width: 100%; padding: 15px 14px; border: 0; font-size: 11px; font-weight: 800;
  letter-spacing: 1.2px; text-align: left; background: transparent;
}
.btn--primary { background: var(--ink); color: var(--panel); }
.btn--primary:hover { background: var(--ink-hover); }
.btn--outline { border: 2px solid var(--ink); background: transparent; }
.btn--outline:hover { background: var(--header); }
.btn--danger { background: var(--danger-fill); color: var(--on-danger); }
.btn--danger:hover { background: var(--danger-fill-hover); }
.btn--danger-outline { border: 2px solid var(--red); color: var(--red7); background: transparent; }
.btn--danger-outline:hover { background: var(--red-light); }
.btn--disabled { border: 2px solid var(--line-strong); color: var(--sub); opacity: 0.45; pointer-events: none; }
.btn--half { width: auto; flex: 1; }
.btn-row { display: flex; gap: 8px; }
.btn-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg-group { display: grid; gap: 1px; background: var(--line-strong); }
.seg-group.cols-2 { grid-template-columns: 1fr 1fr; }
.seg-group.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.seg-group.cols-6 { grid-template-columns: repeat(6, 1fr); }
.seg {
  padding: 15px 11px; min-height: 44px; border: 0; font-size: 11px; font-weight: 700;
  letter-spacing: 0.9px; text-align: left; background: var(--panel); color: var(--sub);
}
.seg.is-on { background: var(--ink); color: var(--panel); }
.seg[disabled] { opacity: 0.45; pointer-events: none; }

.tap {
  width: 44px; height: 44px; flex: none; margin: -9px; border: 0; padding: 0;
  background: transparent; display: flex; align-items: center; justify-content: center;
}
.box {
  width: 26px; height: 26px; border: 2px solid var(--ink); background: transparent;
  color: var(--panel); font-size: 13px; font-weight: 800; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.box.is-on { background: var(--ink); }
.box.is-on::after { content: '\00d7'; }

/* -- fields ----------------------------------------------------------- */

.field-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.9px; color: var(--sub); margin-bottom: 4px; }
.field-grid { display: grid; gap: 10px; }
.field-grid.cols-2 { grid-template-columns: 1fr 1fr; }
input[type="text"], input[type="number"], input[type="password"] {
  width: 100%; padding: 13px 10px; border: 2px solid var(--ink); background: var(--box);
  font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.level-field { display: flex; align-items: center; gap: 19px; padding: 13px 0; border-top: 1px solid var(--line); }
.level-field .lbl { font-size: 11px; font-weight: 700; letter-spacing: 1px; width: 76px; flex: none; }
.level-field input { flex: 1; min-width: 0; }
.level-field .hint { font-size: 10.5px; font-weight: 700; letter-spacing: 0.8px; width: 70px; flex: none; text-align: right; color: var(--sub); }

.toggle-row { display: flex; align-items: flex-start; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.toggle-row .title { font-size: 12px; font-weight: 700; }
.toggle-row .note { margin-top: 2px; }

/* -- tags / badges (colors set inline — many state-dependent combos) ----*/

.tag { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: 1.1px; padding: 3px 5px; }

/* -- ladder / levels --------------------------------------------------- */

.ladder-row { padding: 9px 0; border-top: 1px solid var(--line); }
.ladder-row .top { display: flex; align-items: baseline; gap: 8px; }
.ladder-row .lbl { font-size: 11px; font-weight: 700; letter-spacing: 1px; width: 88px; flex: none; }
.ladder-row .lvl { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ladder-row .dist { margin-left: auto; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--sub); }
.ladder-bar { margin-top: 6px; height: 4px; background: var(--line); }
.ladder-bar .fill { height: 4px; }

.level-row { display: flex; align-items: center; gap: 9px; padding: 10px 0; border-top: 1px solid var(--line); }
.level-row .side { font-size: 10.5px; font-weight: 700; letter-spacing: 1.1px; width: 40px; flex: none; color: var(--sub); }
.level-row .px { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; width: 82px; flex: none; }
.level-row .dist { margin-left: auto; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--sub); }

/* -- log / trade rows --------------------------------------------------- */

.filter-row { display: flex; gap: 1px; background: var(--line-strong); border-bottom: 2px solid var(--ink); }
.filter-row button {
  padding: 14px 6px; min-height: 44px; border: 0; text-align: left; font-size: 10.5px;
  font-weight: 800; letter-spacing: 0.7px; flex: 1; background: var(--panel); color: var(--sub);
}
.filter-row button.is-on { background: var(--ink); color: var(--panel); }

.log-row { display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.log-row .t { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; width: 60px; flex: none; color: var(--sub); }
.log-row .head { display: flex; align-items: center; gap: 6px; }
.log-row .sym { font-size: 10.5px; font-weight: 700; letter-spacing: 0.9px; color: var(--sub); }
.log-row .msg { font-size: 11.5px; line-height: 1.45; margin-top: 4px; }

.book-row { display: flex; align-items: baseline; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.book-row .t { font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; width: 48px; flex: none; color: var(--sub); }
.book-row .contract { font-size: 11.5px; font-weight: 700; }
.book-row .detail { font-size: 11px; font-weight: 700; letter-spacing: 0.8px; margin-top: 2px; color: var(--sub); }
.book-row .pnl { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* -- bottom nav ---------------------------------------------------------*/

.nav {
  flex: none; display: grid; grid-template-columns: repeat(6, 1fr);
  border-top: 2px solid var(--ink); background: var(--header);
}
.nav button {
  padding: 8px 9px 9px; border: 0; border-right: 1px solid var(--line-strong);
  background: var(--header); color: var(--sub); display: flex; flex-direction: column;
  align-items: flex-start; gap: 2px; text-align: left;
}
.nav button:last-child { border-right: none; }
.nav button.is-active { background: var(--panel); color: var(--ink); }
.nav .bar { width: 100%; height: 3px; margin-bottom: 3px; background: transparent; }
.nav button.is-active .bar { background: var(--red); }
.nav .lbl { font-size: 10.5px; font-weight: 800; letter-spacing: 0.7px; }
.nav .sub { font-size: 10px; font-weight: 700; letter-spacing: 0.4px; color: var(--sub); }

/* -- toast / dialog ------------------------------------------------------*/

.toast { flex: none; padding: 9px 16px; background: var(--ink); color: var(--panel); font-size: 11.5px; font-weight: 700; letter-spacing: 0.4px; }

.dialog-overlay {
  position: absolute; left: 0; top: 0; right: 0; bottom: 0; background: rgba(32,30,29,0.55);
  display: flex; align-items: flex-end; z-index: 20;
}
.dialog-sheet {
  width: 100%; background: var(--panel); border-top: 2px solid var(--ink); padding: 18px 16px 16px;
  box-shadow: 0 -12px 32px rgba(45,43,43,0.22);
}
.dialog-sheet .kicker { color: var(--red7); }
.dialog-sheet .title { font-size: 19px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; margin-top: 6px; }
.dialog-sheet .body { margin: 8px 0 0; font-size: 11.5px; line-height: 1.5; color: var(--sub); }
.dialog-line { display: flex; align-items: baseline; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); margin-top: 2px; }
.dialog-line .k { font-size: 11px; font-weight: 700; letter-spacing: 0.9px; color: var(--sub); }
.dialog-line .v { margin-left: auto; font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* -- session wizard -------------------------------------------------------*/

.wiz-step { display: flex; align-items: flex-start; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.wiz-num { width: 26px; height: 26px; flex: none; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; }
.wiz-step .title { font-size: 12px; font-weight: 700; letter-spacing: 0.1px; }
.wiz-step .note { margin-top: 2px; }
.wiz-step input[type="text"] { margin-top: 8px; letter-spacing: 0.6px; }
.wiz-action { margin-top: 9px; padding: 16px 13px; border: 0; background: var(--ink); color: var(--panel); font-size: 11.5px; font-weight: 800; letter-spacing: 1.1px; text-align: left; }

/* -- chart pair (spot + premium side by side once a trade is open) --------*/

.chart-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line-strong); padding: 12px 1px 0; }
.chart-pane { background: var(--panel); padding: 4px 8px 10px; min-width: 0; }

/* -- token gate -----------------------------------------------------------*/

.gate { display: flex; flex-direction: column; justify-content: center; height: 100%; padding: 24px; gap: 14px; }
.gate h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; margin: 0; }
.gate p { font-size: 12px; line-height: 1.5; color: var(--sub); margin: 0; }

/* -- misc ----------------------------------------------------------------*/

.hidden { display: none !important; }
canvas { display: block; width: 100%; }
