/* ===========================================================================
   Trade Desk — a trader's instrument console for live MT5 EAs.
   Identity: amber "live-data" glow on deep petrol slate; numbers are the
   content, so every figure is set in tabular monospace. Labels are
   micro-tracked uppercase legends, like an instrument panel.
   =========================================================================== */
:root {
  --ground:    #0E1419;   /* deep slate-petrol: a desk under monitor glow */
  --panel:     #161E25;   /* raised instrument tile */
  --panel-2:   #1C262E;   /* nested surface / table header */
  --line:      #28333C;   /* hairline rules */
  --text:      #E8EDF0;   /* primary readout */
  --muted:     #8A98A3;   /* legends, secondary */
  --faint:     #5A6873;   /* tertiary / offline */

  --accent:    #E8B23A;   /* amber — live instrument glow (gold-trade fit) */
  --accent-dim:#9A7A2E;
  --go:        #4FD1C5;   /* teal — long / safe / online */
  --go-dim:    #2E6B66;
  --sell:      #F0654A;   /* warm vermilion — short / danger */
  --sell-dim:  #7A3326;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r: 14px;     /* tile radius */
  --r-sm: 9px;
  --pad: clamp(14px, 4vw, 20px);
}

* { box-sizing: border-box; }

html { background: var(--ground); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  /* fixed attachment so the glow covers the whole scrollable page, not just the
     first viewport — fixes the "background cut off at the bottom" on long pages */
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(232,178,58,.07), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(79,209,197,.05), transparent 55%),
    var(--ground);
  background-attachment: fixed;
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

.view { padding: var(--pad); max-width: 560px; margin: 0 auto; }
.hidden { display: none !important; }
main { padding-bottom: 28px; }

/* ---- numbers everywhere ---- */
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* ---- brand / pulse ---- */
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-name {
  font-family: var(--mono); font-weight: 600; font-size: 13px;
  letter-spacing: 0.32em; color: var(--text); text-transform: uppercase;
}
.pulse {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 0 rgba(232,178,58,.5);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(232,178,58,.45); }
  70%  { box-shadow: 0 0 0 7px rgba(232,178,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(232,178,58,0); }
}

/* =================== Login =================== */
.login { display: flex; align-items: center; min-height: 100vh; }
.login-card {
  width: 100%;
  background: linear-gradient(180deg, var(--panel), var(--ground));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: clamp(22px, 7vw, 34px);
}
.login .brand { margin-bottom: 18px; }
.login-sub { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block; font-family: var(--mono); font-size: 10.5px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 7px;
}
input[type="password"] {
  width: 100%; padding: 13px 14px; font-size: 16px; color: var(--text);
  background: var(--ground); border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--mono); letter-spacing: 0.15em;
}
input[type="password"]::placeholder { color: var(--faint); letter-spacing: 0.25em; }
input:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* =================== Buttons =================== */
.btn {
  font-family: var(--sans); font-size: 15px; font-weight: 600;
  padding: 13px 16px; border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; color: var(--text); background: var(--panel-2);
  transition: transform .06s ease, filter .15s ease, background .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  width: 100%; background: var(--accent); color: #1A1205; border: none;
  letter-spacing: 0.01em;
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  padding: 8px 13px; font-size: 13px; font-weight: 500;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

/* =================== Topbar =================== */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 16px; margin-bottom: 4px; border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock {
  font-family: var(--mono); font-size: 13px; color: var(--muted);
  letter-spacing: 0.06em; font-variant-numeric: tabular-nums;
}

/* =================== Status badge =================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; padding: 4px 9px; border-radius: 999px;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; }
.badge.on  { color: var(--go);   background: rgba(79,209,197,.08);  border-color: var(--go-dim); }
.badge.on::before  { background: var(--go); box-shadow: 0 0 6px var(--go); }
.badge.off { color: var(--faint); background: rgba(90,104,115,.08); border-color: var(--line); }
.badge.off::before { background: var(--faint); }

/* =================== EA list tiles =================== */
.ea-list { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; cursor: pointer; position: relative; overflow: hidden;
  transition: border-color .15s ease, transform .06s ease;
}
.tile:hover { border-color: var(--accent-dim); }
.tile:active { transform: scale(.995); }
.tile::after {  /* faint amber edge: the "this is live" tell */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(var(--accent), var(--accent-dim)); opacity: .0;
  transition: opacity .2s ease;
}
.tile.is-online::after { opacity: .9; }

.tile-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.tile-id { display: flex; flex-direction: column; gap: 2px; }
.tile-symbol { font-family: var(--mono); font-weight: 600; font-size: 16px; letter-spacing: 0.02em; }
.tile-magic { font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: 0.08em; }

.tile-hero { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.hero-eq { display: flex; flex-direction: column; gap: 3px; }
.hero-num { font-family: var(--mono); font-size: 30px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.legend { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.tile-side { text-align: right; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.tile-pl { font-family: var(--mono); font-size: 17px; font-weight: 600; }
.tile-arm { font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; }

.dir-buy  { color: var(--go); }
.dir-sell { color: var(--sell); }
.dir-flat { color: var(--muted); }
.pl-pos { color: var(--go); }
.pl-neg { color: var(--sell); }

/* equity-vs-HWM micro track */
.hwm-track { margin-top: 14px; }
.hwm-bar { height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.hwm-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); }
.hwm-meta { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--mono); font-size: 10px; color: var(--faint); letter-spacing: 0.06em; }

/* empty / no EAs */
.empty {
  text-align: center; color: var(--muted); padding: 56px 20px;
  border: 1px dashed var(--line); border-radius: var(--r); margin-top: 18px;
}
.empty-title { font-family: var(--mono); letter-spacing: 0.1em; color: var(--text); margin-bottom: 8px; }
.empty p { font-size: 14px; margin: 0; }

/* =================== Detail =================== */
.detail-head { display: flex; align-items: center; justify-content: space-between; margin: 16px 0 6px; }
.back {
  display: inline-flex; align-items: center; gap: 7px; background: none; border: none;
  color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em;
  cursor: pointer; padding: 6px 2px;
}
.back:hover { color: var(--accent); }
.detail-title { font-family: var(--mono); font-size: 20px; font-weight: 600; margin: 6px 0 2px; letter-spacing: 0.01em; }
.detail-sync { font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: 0.06em; margin-bottom: 18px; }

.hero-panel {
  background: linear-gradient(180deg, var(--panel), var(--ground));
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px; margin-bottom: 16px; position: relative; overflow: hidden;
}
.hero-panel::after {
  content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(232,178,58,.12), transparent 70%);
}
.hero-panel .hero-num { font-size: 42px; }
.hero-panel .legend { margin-bottom: 9px; }
.hero-row { display: flex; align-items: baseline; gap: 14px; margin-top: 12px; }
.hero-row .tile-pl { font-size: 20px; }
.hero-bal { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }

/* $50K target: progress bar + escalating affirmation */
.target { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); position: relative; z-index: 1; }
.target-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.target-lbl { font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; color: var(--text); }
.target-pct { font-family: var(--mono); font-size: 12px; color: var(--accent); font-variant-numeric: tabular-nums; }
.target-bar { height: 8px; border-radius: 5px; background: var(--panel-2); overflow: hidden; }
.target-fill { height: 100%; border-radius: 5px;
  background: linear-gradient(90deg, var(--accent-dim), var(--accent));
  box-shadow: 0 0 12px rgba(232,178,58,.45); transition: width .5s ease; }
.target-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-top: 9px; }
.affirm { font-family: var(--sans); font-size: 12.5px; color: var(--muted); font-style: italic; }
.target-left { font-family: var(--mono); font-size: 11px; color: var(--faint); white-space: nowrap; letter-spacing: 0.02em; }

.hero-sub { display: flex; justify-content: space-between; margin-top: 14px;
  font-family: var(--mono); font-size: 11px; color: var(--faint); letter-spacing: 0.04em;
  position: relative; z-index: 1; }

/* vitals grid */
.vitals { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 16px; }
.vital { background: var(--panel); padding: 13px 15px; }
.vital .legend { display: block; margin-bottom: 5px; }
.vital-val { font-family: var(--mono); font-size: 15px; font-weight: 500; }

/* positions */
.section-label { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--muted); margin: 22px 2px 11px;
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pos-count { display: inline-block; min-width: 17px; text-align: center; font-size: 9.5px;
  color: var(--accent); background: rgba(232,178,58,.1); border: 1px solid var(--accent-dim);
  border-radius: 999px; padding: 1px 6px; margin-left: 4px; letter-spacing: 0; }
.pos-sum { display: inline-flex; align-items: baseline; gap: 7px; text-transform: none; letter-spacing: 0; }
.pos-sum-lbl { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--muted); }
.pos-sum-val { font-family: var(--mono); font-size: 15px; font-weight: 600;
  font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.tag-l { color: var(--go); font-weight: 600; } .tag-s { color: var(--sell); font-weight: 600; }
.pl-pos { color: var(--go); } .pl-neg { color: var(--sell); }

/* position cards: $ P/L is the hero number; R demoted to a labeled field */
.pcards { display: flex; flex-direction: column; gap: 11px; }
.pcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 16px; position: relative; overflow: hidden; }
.pcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }
.pcard.is-long::before  { background: var(--go); }
.pcard.is-short::before { background: var(--sell); }
.pcard-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.pcard-id { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.pcard-side { font-family: var(--mono); font-size: 15px; font-weight: 600; letter-spacing: 0.04em; }
.pcard-vol { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.pcard-pl { font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; }
.pcard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.pf { display: flex; flex-direction: column; gap: 3px; }
.pf .legend { font-size: 9px; letter-spacing: 0.16em; }
.pf-val { font-family: var(--mono); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.chip { font-family: var(--mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.chip.on { color: var(--accent); border-color: var(--accent-dim); }
.pos-empty-card { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r);
  color: var(--faint); text-align: center; padding: 26px; font-family: var(--mono);
  font-size: 13px; letter-spacing: 0.05em; }

/* status chip in hero + plain-language metric helpers */
.status-chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  padding: 4px 10px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.st-ok   { color: var(--go);   background: rgba(79,209,197,.08); border-color: var(--go-dim); }
.st-halt { color: var(--sell); background: rgba(240,101,74,.1);  border-color: var(--sell-dim); }
.hero-unit { font-size: 11px; color: var(--muted); font-weight: 400; }
.v-unit { font-size: 10px; color: var(--faint); letter-spacing: 0; }
.v-muted { color: var(--faint); font-weight: 400; }
.v-alert { color: var(--sell); }

/* =================== Settings panel =================== */
.settings-paused { font-size: 10px; color: var(--faint); font-family: var(--mono); letter-spacing: 0.05em; margin-left: 6px; }
.settings-toggle {
  background: none; border: 1px solid var(--line); color: var(--muted);
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px; cursor: pointer;
  transition: color .15s ease, border-color .15s ease;
}
.settings-toggle:hover { color: var(--accent); border-color: var(--accent-dim); }
.settings-panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px;
}
.settings-group-label {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--accent-dim); margin-top: 6px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.settings-group-label:first-child { margin-top: 0; }
.settings-row { display: flex; flex-direction: column; gap: 6px; }
.settings-input-row { display: flex; gap: 8px; align-items: center; }
.settings-input, .settings-select {
  flex: 1; padding: 9px 12px; background: var(--ground); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--text); font-family: var(--mono); font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.settings-select { cursor: pointer; }
.settings-input:focus-visible, .settings-select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn-apply-setting {
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; padding: 9px 14px; border-radius: var(--r-sm);
  background: var(--accent); color: #1A1205; border: none; cursor: pointer; white-space: nowrap;
  transition: filter .15s ease;
}
.btn-apply-setting:hover { filter: brightness(1.08); }
.settings-hint { font-family: var(--mono); font-size: 10px; color: var(--faint); letter-spacing: 0.04em; }
/* Require-momentum toggle */
.toggle-row { display: flex; }
.btn-toggle {
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 0.12em;
  padding: 9px 22px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--muted); cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.btn-toggle.toggle-on {
  background: rgba(232,178,58,.12); color: var(--accent); border-color: var(--accent);
}

/* =================== Sticky command dock =================== */
/* Pinned to the bottom of the viewport so arm/flatten are ALWAYS one tap away —
   a hurried user never scrolls to find them. .rail-spacer reserves page space so
   the dock never covers the last position card. */
.rail-spacer { height: 132px; }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(14,20,25,.4), var(--ground) 38%);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.dock > * { max-width: 560px; margin: 0 auto; }
.dock-arm { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 9px; margin-bottom: 9px; }
.btn-arm { font-family: var(--mono); font-size: 15px; font-weight: 600; letter-spacing: 0.06em;
  padding: 15px 8px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--panel-2); cursor: pointer;
  transition: transform .06s ease, background .15s ease; -webkit-tap-highlight-color: transparent; }
.btn-arm:active { transform: scale(.97); }
.btn-buy  { color: var(--go);   border-color: var(--go-dim); }
.btn-sell { color: var(--sell); border-color: var(--sell-dim); }
.btn-flat { color: var(--muted); }
.btn-arm.active-buy  { background: rgba(79,209,197,.18); color: var(--go);   border-color: var(--go); }
.btn-arm.active-sell { background: rgba(240,101,74,.18); color: var(--sell); border-color: var(--sell); }
.btn-arm.active-flat { background: var(--panel-2); color: var(--text); border-color: var(--muted); }
.btn-flatten {
  display: block; width: 100%; font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; padding: 12px;
  border-radius: var(--r-sm); cursor: pointer; color: var(--sell);
  background: transparent; border: 1px solid var(--sell-dim);
  transition: background .15s ease, transform .06s ease;
}
.btn-flatten:hover { background: var(--sell); color: #1A0B07; border-color: var(--sell); }
.btn-flatten:active { transform: scale(.99); }

/* toast — sits above the dock; can carry an inline action (Undo) */
.toast {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%) translateY(20px);
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--accent-dim); color: var(--text);
  font-family: var(--mono); font-size: 13px; letter-spacing: 0.04em;
  padding: 10px 12px 10px 18px; border-radius: 999px; box-shadow: 0 8px 30px rgba(0,0,0,.55);
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
.toast-btn { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--accent); background: rgba(232,178,58,.12); border: 1px solid var(--accent-dim);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; }
.toast-btn:active { transform: scale(.96); }

.err { color: var(--sell); font-size: 13px; margin: 12px 0 0; min-height: 1.2em; }

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
  * { transition: none !important; }
}

/* =================== Reset daily lock =================== */
.reset-lock-row {
  display: flex; align-items: center; gap: 12px;
  margin: -4px 0 16px; padding: 10px 14px;
  background: rgba(240,101,74,.07); border: 1px solid var(--sell-dim);
  border-radius: var(--r);
}
.btn-reset-lock {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  font-weight: 600; color: var(--sell); background: rgba(240,101,74,.14);
  border: 1px solid var(--sell-dim); border-radius: 999px;
  padding: 6px 16px; cursor: pointer; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}
.btn-reset-lock:hover { background: rgba(240,101,74,.26); border-color: var(--sell); }
.btn-reset-lock:active { transform: scale(.96); }
.reset-lock-hint { font-size: 11px; color: var(--faint); font-family: var(--mono); }

/* =================== Activity log panel =================== */
#logPanel {
  max-height: 260px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
#logPanel::-webkit-scrollbar { width: 4px; }
#logPanel::-webkit-scrollbar-track { background: transparent; }
#logPanel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
#logPanel::-webkit-scrollbar-thumb:hover { background: var(--muted); }
.log-entry {
  display: grid; grid-template-columns: 72px 1fr;
  gap: 10px; align-items: baseline;
  padding: 6px 0; border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 12px;
}
.log-entry:last-child { border-bottom: none; }
.log-ts { color: var(--faint); font-size: 10.5px; letter-spacing: 0.04em; white-space: nowrap; }
.log-msg { color: var(--text); line-height: 1.4; }
.log-info .log-msg  { color: var(--muted); }
.log-warn .log-msg  { color: var(--sell); }
.log-trade .log-msg { color: var(--go); }
.log-empty { color: var(--faint); font-size: 12px; font-family: var(--mono); padding: 6px 0; }
