:root {
  --bg: #0B0E14;
  --surface: #151A23;
  --surface2: #1C2330;
  --border: #242C3A;
  --buy: #16C784;
  --sell: #EA3943;
  --info: #8A94A6;
  --accent: #F0B90B;
  --news: #FFA726;
  --text: #E6E8EC;
  --muted: #8A94A6;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100%; }
body { padding-top: var(--safe-top); }
button, input { font-family: inherit; }
a { color: var(--accent); }
.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 12px;
  background: var(--bg);
}
.appbar h1 { margin: 0; font-size: 20px; font-weight: 700; flex: 1; display: flex; align-items: center; gap: 10px; white-space: nowrap; overflow: hidden; }
.appbar h1 img { width: 30px; height: 30px; border-radius: 7px; }
.icon-btn {
  background: none; border: 0; color: var(--text); width: 40px; height: 40px;
  border-radius: 20px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn:active { background: var(--surface2); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: color-mix(in srgb, var(--pill, var(--buy)) 12%, transparent);
  color: var(--pill, var(--buy));
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.banner {
  margin: 0 12px 12px; padding: 12px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  color: var(--text); font-size: 14px; line-height: 1.4;
}
.banner strong { color: var(--accent); }
.list { padding: 4px 12px calc(24px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; cursor: pointer; position: relative;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--dir, var(--info));
}
.card-body { padding: 12px 12px 12px 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.pair { font-weight: 700; font-size: 18px; flex: 1; }
.time { color: var(--muted); font-size: 13px; font-weight: 600; margin-left: auto; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border-radius: 6px; font-weight: 800; font-size: 10px; letter-spacing: .5px;
  border: 1px solid color-mix(in srgb, currentColor 60%, transparent);
  background: color-mix(in srgb, currentColor 14%, transparent);
}
.badge-dir {
  background: var(--dir, var(--info)); color: #fff; border: 0;
  font-size: 13px; font-weight: 800; padding: 4px 8px; letter-spacing: 0;
  border-radius: 6px;
}
.badge-dir svg { width: 16px; height: 16px; fill: #fff; }
.badge-open { color: var(--buy); }
.badge-closed { color: var(--muted); }
.badge-updated, .badge-moved { color: var(--accent); }
.badge-news { color: var(--news); font-size: 9px; }
.badge-label { letter-spacing: 1px; font-size: 11px; }
.prices { display: flex; margin-top: 10px; gap: 8px; }
.price { flex: 1; min-width: 0; }
.price .k { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .6px; }
.price .v { font-size: 16px; font-weight: 600; }
.price .old { color: var(--muted); font-size: 11px; text-decoration: line-through; display: block; }
.closed-line { margin-top: 8px; font-weight: 700; font-size: 14px; }
.reason {
  margin-top: 8px; background: var(--surface2); border-radius: 8px;
  padding: 8px 10px; color: var(--muted); font-size: 13px; line-height: 1.35;
}
.updates { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.update { font-size: 13px; line-height: 1.35; display: flex; gap: 6px; align-items: flex-start; flex-wrap: wrap; }
.update .t { color: var(--muted); font-size: 12px; min-width: 58px; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.footer-link { text-align: center; padding: 8px 0 4px; }
.footer-link button { background: none; border: 0; color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.day { color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 1.2px; padding: 14px 4px 2px; }
.hist-meta { color: var(--muted); font-size: 12px; padding: 4px; }

/* Detail */
.detail { padding: 8px 16px calc(24px + var(--safe-bottom)); }
.hero {
  padding: 18px; border-radius: 16px; text-align: center;
  background: color-mix(in srgb, var(--dir, var(--info)) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--dir, var(--info)) 50%, transparent);
}
.hero .kind { font-size: 32px; font-weight: 900; letter-spacing: 2px; color: var(--dir, var(--info)); }
.hero .pair { font-size: 22px; font-weight: 600; margin-top: 2px; display: block; }
.hero .when { color: var(--muted); font-size: 13px; margin-top: 6px; }
.hero-tags { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.section { margin-top: 16px; }
.section h2 { color: var(--muted); font-size: 12px; letter-spacing: 1px; font-weight: 700; margin: 0 0 8px; }
.kv { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 4px 0; }
.kv-row { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; border-top: 1px solid var(--border); }
.kv-row:first-child { border-top: 0; }
.kv-row .k { color: var(--muted); font-size: 13px; }
.kv-row .v { font-weight: 700; font-size: 16px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; border-radius: 28px; padding: 14px 16px; font-weight: 700; font-size: 15px;
  border: 0; cursor: pointer; margin-top: 12px;
}
.btn-fill { background: var(--accent); color: #111; }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--text); }
.btn-danger { color: var(--sell); background: none; border: 0; font-weight: 700; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Settings */
.settings { padding: 16px 16px calc(24px + var(--safe-bottom)); }
.status-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: flex; gap: 12px; align-items: flex-start; }
.status-card .dot { width: 16px; height: 16px; border-radius: 50%; margin-top: 2px; flex-shrink: 0; }
.status-card h3 { margin: 0; font-size: 16px; }
.status-card p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.field { margin-top: 12px; }
.field label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.field input {
  width: 100%; background: var(--surface2); border: 0; border-radius: 10px;
  color: var(--text); padding: 12px 12px; font-family: ui-monospace, monospace; font-size: 14px;
}
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.ver { text-align: center; color: var(--muted); font-size: 12px; margin-top: 20px; }

/* Dialog */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.dialog {
  background: #1a2030; border-radius: 28px; padding: 22px 22px 12px;
  width: min(400px, 100%); color: var(--text); box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
.dialog h3 { margin: 0 0 10px; font-size: 22px; font-weight: 700; }
.dialog p { margin: 0 0 16px; color: #d7dbe3; font-size: 15px; line-height: 1.4; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-actions button {
  background: none; border: 0; font-weight: 700; font-size: 16px;
  padding: 12px 14px; cursor: pointer; color: var(--accent);
}
.dialog-actions .danger { color: var(--sell); }

.snack {
  position: fixed; left: 12px; right: 12px; bottom: calc(16px + var(--safe-bottom));
  background: var(--surface2); color: var(--text); padding: 12px 16px; border-radius: 8px;
  z-index: 60; text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.hidden { display: none !important; }

/* Combined Fundamentals / Plan Info notes */
.note-label { font-weight: 700; }
.note-plan-break { height: 8px; }

/* v1.3.5 multi-select delete */
.card { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.sel-check { display: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--muted); flex-shrink: 0; box-sizing: border-box; }
.view.selecting .sel-check { display: inline-block; }
.card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); opacity: 1 !important; }
.card.selected .sel-check {
  border-color: var(--accent); background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23101521' d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
  background-size: 16px 16px; background-repeat: no-repeat; background-position: center;
}
.view.selecting .footer-link { display: none; }
.select-bar h1 { font-size: 18px; }
.text-btn { background: none; border: 0; color: var(--accent); font-weight: 700; font-size: 15px; padding: 8px 6px; cursor: pointer; white-space: nowrap; }
.danger-btn { color: var(--sell); }
.danger-btn:disabled { color: var(--muted); cursor: default; }

/* v1.3.8 History — live trade log layout (matches bluecollarfx.net) */
.history-page { padding: 4px 12px calc(24px + var(--safe-bottom)); }
.trade-stats {
  list-style: none; margin: 0 0 10px; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.trade-stats li {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px; min-width: 0;
}
.trade-stats .k { display: block; color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.trade-stats .v { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.trade-stats .v.up { color: var(--buy); }
.trade-stats .v.down { color: var(--sell); }
.trade-range { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0 0 8px; padding: 0 4px; }
.trade-note { font-size: 12px; margin-bottom: 16px; }
.trade-log-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden;
}
.trade-sec {
  padding: 10px 14px 8px; color: var(--accent); font-size: 11px;
  font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  background: var(--surface2); border-top: 1px solid var(--border);
}
.trade-sec:first-child { border-top: 0; }
.trade-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  grid-template-areas: "top pips result" "bot pips result";
  gap: 2px 10px; padding: 12px 14px; border-top: 1px solid var(--border);
  align-items: center; min-width: 0; cursor: pointer;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.trade-log-wrap > .trade-row:first-child,
.trade-log-wrap > .trade-sec:first-child + .trade-row { border-top: 0; }
.trade-top { grid-area: top; display: flex; align-items: baseline; flex-wrap: wrap; gap: 0; min-width: 0; }
.trade-bot { grid-area: bot; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; min-width: 0; }
.trade-pair { font-weight: 700; font-size: 16px; color: var(--text); min-width: 0; }
.trade-side { font-size: 11px; font-weight: 800; letter-spacing: 0.4px; margin-left: 8px; }
.trade-side.buy { color: var(--buy); }
.trade-side.sell { color: var(--sell); }
.trade-date, .trade-prices { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 0; }
.trade-date { font-weight: 600; }
.trade-pips {
  grid-area: pips; font-weight: 800; font-variant-numeric: tabular-nums;
  font-size: 16px; white-space: nowrap;
}
.trade-result {
  grid-area: result; font-size: 11px; font-weight: 800; letter-spacing: 0.4px;
  text-transform: uppercase; padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.trade-pips.win, .trade-result.win { color: var(--buy); }
.trade-pips.loss, .trade-result.loss { color: var(--sell); }
.trade-pips.be, .trade-result.be { color: var(--muted); }
.trade-result.win { background: color-mix(in srgb, var(--buy) 14%, transparent); }
.trade-result.loss { background: color-mix(in srgb, var(--sell) 14%, transparent); }
.trade-result.be { background: color-mix(in srgb, var(--muted) 14%, transparent); }
.trade-row.selected { background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.trade-row .sel-check { margin-right: 8px; align-self: center; }
.view.selecting .trade-row .sel-check { display: inline-block; }
.trade-row.selected .sel-check {
  border-color: var(--accent); background: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23101521' d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
  background-size: 16px 16px; background-repeat: no-repeat; background-position: center;
}
