/* ============================================================
   ZENITH — Trading Bot Dashboard
   Design tokens + base styles. Dark terminal aesthetic.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* surfaces */
  --bg:        #0F1117;
  --card:      #11141A;
  --card-2:    #1A212B;
  --card-3:    #11151C;
  --border:    #2A2F3A;
  --border-bri:#3A4250;

  /* semantic */
  --green:     #00C896;
  --green-2:   #14E0A8;
  --green-dim: rgba(0, 200, 150, 0.12);
  --green-line:rgba(0, 200, 150, 0.35);
  --red:       #FF4D4D;
  --red-dim:   rgba(255, 77, 77, 0.12);
  --amber:     #F5A623;
  --amber-dim: rgba(245, 166, 35, 0.13);
  --blue:      #4D8DFF;
  --blue-dim:  rgba(77, 141, 255, 0.12);

  /* accent */
  --accent:    #00C896;
  --fg:        #E6E8EB;

  /* text */
  --text:      #E6E8EB;
  --text-2:    #AEB4BD;
  --muted:     #8A8F98;
  --faint:     #5C636E;

  /* type */
  --sans: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  /* layout */
  --rail: 56px;
  --header-h: 48px;
  --radius: 6px;
  --radius-sm: 4px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection { background: var(--green-dim); }

/* scrollbars */
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #262c37; border-radius: 6px; border: 2px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #333b48; }

/* ---------- numeric helpers ---------- */
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; letter-spacing: -0.2px; }
.tnum { font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.amber { color: var(--amber); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ============================================================
   APP SHELL
   ============================================================ */
.app { display: flex; height: 100dvh; height: 100vh; width: 100%; }
@supports (height: 100dvh) { .app { height: 100dvh; } }

/* ---- sidebar rail ---- */
.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: #0C0E13;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0;
  z-index: 30;
}
.rail-logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: #0F1117 url('/static/icons/icon-192.png') center / cover no-repeat;
  display: grid; place-items: center;
  margin-bottom: 14px;
  box-shadow: 0 0 0 1px var(--border);
  text-decoration: none;
  font-size: 0;  /* hide any legacy text content */
}
.rail-group { display: flex; flex-direction: column; gap: 4px; width: 100%; align-items: center; }
.rail-sep { width: 24px; height: 1px; background: var(--border); margin: 9px 0; }
.rail-spacer { flex: 1; }
.rail-btn {
  width: 38px; height: 38px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--muted); cursor: pointer; position: relative;
  border: none; background: transparent; transition: color .12s, background .12s;
  text-decoration: none;
}
.rail-btn:hover { color: var(--text); background: #161b22; }
.rail-btn.active { color: var(--green); background: var(--green-dim); }
.rail-btn.active::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--green);
}
.rail-btn svg { width: 19px; height: 19px; }

/* tooltip */
.rail-btn[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--card-2); color: var(--text); border: 1px solid var(--border);
  padding: 4px 8px; border-radius: 5px; font-size: 11px; white-space: nowrap;
  font-family: var(--sans); z-index: 60; pointer-events: none;
  box-shadow: 0 6px 18px rgba(0,0,0,.5);
}

/* header / stat-label tooltip (e.g. R explainer) */
th[data-tip], .lbl[data-tip], .card-title[data-tip] { position: relative; cursor: help; }
th[data-tip]:hover::after, .lbl[data-tip]:hover::after, .card-title[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; top: calc(100% + 6px);
  background: var(--card-2); color: var(--text); border: 1px solid var(--border);
  padding: 7px 9px; border-radius: 6px; font-size: 11px; line-height: 1.45;
  font-weight: 400; white-space: normal; width: 230px; text-align: left;
  text-transform: none; letter-spacing: normal; font-family: var(--sans);
  z-index: 60; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.5);
}
th[data-tip]:hover::after { right: 0; }
.lbl[data-tip]:hover::after, .card-title[data-tip]:hover::after { left: 0; }
.card-title[data-tip] { display: inline-block; }
.stat.tip-card { overflow: visible; }

/* ---- main column ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* top header */
.topbar {
  height: var(--header-h); flex: 0 0 var(--header-h);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px; background: #0d1015;
}
.wordmark { font-weight: 700; font-size: 15px; letter-spacing: 0.16em; line-height: 1; white-space: nowrap; }
.wordmark .dot { color: var(--green); letter-spacing: 0; }
.topbar-ticker { display: flex; align-items: baseline; gap: 9px; }
.topbar-ticker .pair { font-size: 11px; color: var(--muted); letter-spacing: .5px; }
.topbar-ticker .price { font-size: 18px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.balance-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }

.content { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }
.content.content-flush { padding: 6px !important; }
.content-narrow { max-width: 1280px; }

/* ============================================================
   PRIMITIVES
   ============================================================ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.card.bright { border-color: var(--border-bri); }
.card.accent { border-color: var(--green-line); box-shadow: inset 0 0 0 1px rgba(0,200,150,.06); }
.card-top-accent { border-top: 2px solid var(--green); }

.card-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 600; margin: 0 0 10px;
}
.card-title.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title .meta { font-family: var(--mono); font-size: 11.5px; letter-spacing: -.2px; text-transform: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.3px; }
.page-sub { color: var(--muted); font-size: 12.5px; margin: 3px 0 0; }

/* grids */
.grid { display: grid; gap: 12px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-row-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

/* stat card */
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 14px; position: relative; overflow: hidden; }
.stat .lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.stat .val { font-size: 24px; font-weight: 600; margin-top: 7px; letter-spacing: -.5px; }
.stat .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.stat.accent-green::after, .stat.accent-red::after, .stat.accent-blue::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
}
.stat.accent-green::after { background: var(--green); }
.stat.accent-red::after   { background: var(--red); }
.stat.accent-blue::after  { background: var(--blue); }

/* pills & badges */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  font-family: var(--sans); letter-spacing: .3px;
}
.pill .led { width: 6px; height: 6px; border-radius: 50%; }
.pill.green { background: var(--green-dim); color: var(--green); }
.pill.red   { background: var(--red-dim);   color: var(--red); }
.pill.amber { background: var(--amber-dim); color: var(--amber); }
.pill.blue  { background: var(--blue-dim);  color: var(--blue); }
.pill.gray  { background: #1f262f; color: var(--text-2); }

.dir-badge {
  font-family: var(--sans); font-size: 10.5px; font-weight: 700; letter-spacing: .6px;
  padding: 2px 7px; border-radius: 4px;
}
.dir-badge.long  { background: var(--green-dim); color: var(--green); }
.dir-badge.short { background: var(--red-dim);   color: var(--red); }

.led { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.led.green { background: var(--green); box-shadow: 0 0 7px rgba(0,200,150,.7); }
.led.red   { background: var(--red);   box-shadow: 0 0 7px rgba(255,77,77,.6); }
.led.amber { background: var(--amber); box-shadow: 0 0 7px rgba(245,166,35,.6); }
.led.gray  { background: var(--faint); }

/* buttons */
.btn {
  font-family: var(--sans); font-size: 12.5px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid transparent; display: inline-flex; align-items: center;
  justify-content: center; gap: 7px; transition: all .12s; line-height: 1;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--green); color: #06231b; }
.btn-primary:hover { background: var(--green-2); }
.btn-ghost { background: #1b222c; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #222a35; border-color: var(--border-bri); }
.btn-red-outline { background: transparent; color: var(--red); border-color: rgba(255,77,77,.4); }
.btn-red-outline:hover { background: var(--red-dim); }
.btn-red { background: var(--red); color: #2a0808; }
.btn-red:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.link { color: var(--green); cursor: pointer; font-size: 12px; font-weight: 500; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link.muted { color: var(--muted); }
.link.red { color: var(--red); opacity: .85; }

/* inputs */
.input, .select {
  background: var(--card-3); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12.5px;
  font-family: var(--sans); width: 100%; outline: none;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .select:focus { border-color: var(--green-line); }
.input.mono { font-family: var(--mono); }
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 0 transparent !important;
  box-shadow: none !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  background: var(--card-3) !important;
  transition: background-color 5000s ease-in-out 0s;
}
.field-lbl { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 5px; display: block; }
.input-suffix { position: relative; }
.input-suffix .suffix { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; }

/* toggle switch */
.switch { width: 34px; height: 19px; border-radius: 999px; background: #2a323d; position: relative; cursor: pointer; transition: background .15s; flex: none; border: none; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #8a929e; transition: .15s; }
.switch.on { background: var(--green); }
.switch.on::after { left: 17px; background: #06231b; }
.switch.amber.on { background: var(--amber); }

.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; }
.toggle-row + .toggle-row { border-top: 1px solid var(--border); }

/* sliders */
.slider-row { margin-bottom: 16px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.slider-head .lbl { font-size: 12px; color: var(--text-2); }
.slider-head .val { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--green); }
input[type=range] { -webkit-appearance: none; width: 100%; height: 4px; border-radius: 3px; background: #232a34; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%; background: var(--green); cursor: pointer; box-shadow: 0 0 0 3px rgba(0,200,150,.18); }
input[type=range]::-moz-range-thumb { width: 15px; height: 15px; border: none; border-radius: 50%; background: var(--green); cursor: pointer; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap; user-select: none;
}
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text-2); }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #1d232c; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover { background: #131820; }
.tbl tbody tr.alt { background: rgba(255,255,255,.012); }
.tbl td.mono, .tbl th.mono { font-family: var(--mono); }
.row-win { box-shadow: inset 3px 0 0 var(--green-line); }
.row-loss { box-shadow: inset 3px 0 0 rgba(255,77,77,.35); }

.sort-arrow { font-size: 9px; margin-left: 3px; color: var(--green); }

/* pagination */
.pager { display: flex; align-items: center; gap: 4px; }
.pager button, .pager a, .pager span { background: transparent; border: 1px solid var(--border); color: var(--text-2); min-width: 26px; height: 26px; padding: 0 5px; border-radius: 5px; cursor: pointer; font-size: 12px; font-family: var(--mono); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.pager button:hover, .pager a:hover { border-color: var(--border-bri); }
.pager button.active, .pager .active { background: var(--green-dim); border-color: var(--green-line); color: var(--green); }
.pager button:disabled, .pager .disabled { opacity: .4; cursor: default; }

/* progress bar */
.pbar { height: 6px; border-radius: 3px; background: #232a34; overflow: hidden; }
.pbar > span { display: block; height: 100%; border-radius: 3px; }

/* misc layout helpers */
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; }
.vcenter { display: flex; align-items: center; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.wrap { flex-wrap: wrap; }

/* timeframe selector */
.tf-tabs { display: flex; gap: 2px; }
.tf-tabs button {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 11px; font-weight: 600; font-family: var(--sans); padding: 4px 8px;
  border-bottom: 2px solid transparent; letter-spacing: .4px;
}
.tf-tabs button:hover { color: var(--text-2); }
.tf-tabs button.active { color: var(--green); border-bottom-color: var(--green); }

/* settings tab bar */
.settings-tabs { display: flex; background: var(--card-3); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px; gap: 4px; }
.settings-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
  background: transparent; color: var(--muted); font-family: var(--sans); font-size: 13px; font-weight: 600;
  transition: background .12s, color .12s, border-color .12s;
}
.settings-tab svg { width: 15px; height: 15px; }
.settings-tab:hover { color: var(--text-2); }
.settings-tab.active { background: var(--card-2); color: var(--text); border-color: var(--border-bri); }

/* toggle chips (sessions / symbols) */
.chip-toggle {
  background: var(--card-3); border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; font-size: 11.5px; font-weight: 600; font-family: var(--sans);
  padding: 6px 13px; border-radius: 999px; transition: all .12s; user-select: none;
}
.chip-toggle:hover { border-color: var(--border-bri); color: var(--text-2); }
.chip-toggle.on { background: var(--green-dim); border-color: var(--green-line); color: var(--green); }

/* segmented control */
.seg { display: inline-flex; background: var(--card-3); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.seg button, .seg a { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 11.5px; font-weight: 600; font-family: var(--sans); padding: 5px 12px; border-radius: 3px; text-decoration: none; display: inline-block; }
.seg button.active, .seg a.active { background: #232c37; color: var(--text); }

/* status grid (bot health) */
/* Position mobile cards */
.pos-cards-mobile { display: none; }

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.status-cell { background: var(--card); padding: 9px 11px; }
.status-cell .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.status-cell .v { font-family: var(--mono); font-size: 13px; margin-top: 3px; display: flex; align-items: center; gap: 6px; }

/* heatmap */
.heat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.heat-cell { aspect-ratio: 1; border-radius: 2px; background: #1b212a; }
.heat-dow { font-size: 9px; color: var(--faint); text-align: center; padding-bottom: 4px; }

/* info / callout boxes */
.callout { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12px; display: flex; gap: 9px; align-items: flex-start; }
.callout.blue { background: var(--blue-dim); border: 1px solid rgba(77,141,255,.25); color: #b8d2ff; }
.callout.green { background: var(--green-dim); color: var(--green); }
.callout.amber { background: var(--amber-dim); color: var(--amber); }
.callout svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }

/* danger zone */
.danger { border-color: rgba(255,77,77,.35) !important; }
.danger .card-title { color: var(--red); }

/* hero stats (public/track record) */
.hero-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.hero-stat { padding: 22px 24px; border-right: 1px solid var(--border); }
.hero-stat:last-child { border-right: none; }
.hero-stat .v { font-size: 38px; font-weight: 700; letter-spacing: -1px; }
.hero-stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-top: 4px; }

/* telegram log */
.tg-log { display: flex; flex-direction: column; }
.tg-row { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid #1d232c; align-items: flex-start; }
.tg-row:last-child { border-bottom: none; }
.tg-row .ts { font-family: var(--mono); font-size: 11px; color: var(--muted); flex: none; width: 64px; }
.tg-row .ic { flex: none; width: 16px; text-align: center; }
.tg-row .msg { font-size: 12px; color: var(--text-2); }

/* hbar chart rows */
.hbar-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: center; margin-bottom: 9px; font-size: 11.5px; }
.hbar-row .name { color: var(--text-2); }
.hbar-track { height: 16px; background: #1b212a; border-radius: 3px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 3px; }
.hbar-row .meta { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; }

/* two col */
.cols { display: grid; gap: 14px; }

/* grid helpers */
.grid-2 { grid-template-columns: 1fr 1fr; }

/* hero card (drawdown) */
.card.hero { background: linear-gradient(180deg, rgba(255,77,77,.025), transparent 40%), var(--card); }

/* win-rate progress list */
.wr-list { display: flex; flex-direction: column; gap: 13px; }
.wr-row .wr-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.wr-row .wr-name { font-size: 12.5px; color: var(--text-2); font-weight: 500; text-transform: capitalize; }
.wr-row .wr-val { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.wr-row .wr-val .ct { color: var(--muted); margin-left: 6px; font-size: 11px; }
.pbar { height: 6px; border-radius: 999px; background: var(--card-3); overflow: hidden; }
.pbar > span { display: block; height: 100%; border-radius: 999px; }
.pbar.green > span { background: var(--green); }
.pbar.red > span   { background: var(--red); }

/* hold time analysis */
.hold { display: grid; grid-template-columns: 1fr 1fr auto; gap: 18px; align-items: center; }
.hold-col .hl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; }
.hold-col .hv { font-family: var(--mono); font-size: 28px; font-weight: 600; margin-top: 6px; letter-spacing: -.5px; }
.hold-sep { width: 1px; align-self: stretch; background: var(--border); }
.hold-bars { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.hold-bar-row { display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: center; }
.hold-bar-row .k { font-size: 11px; color: var(--muted); }
.hold-track { height: 8px; border-radius: 999px; background: var(--card-3); overflow: hidden; }
.hold-track > span { display: block; height: 100%; border-radius: 999px; }
.hold-insight { font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.hold-insight b { color: var(--text-2); font-weight: 600; }


/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .rail { display: none; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .stat-row-5 { grid-template-columns: repeat(2, 1fr); }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stat:nth-child(2) { border-right: none; }
  .topbar { padding: 0 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .hold { grid-template-columns: 1fr 1fr; }
  .hold-sep { display: none; }
  .hold-bars { grid-column: 1 / -1; }
}

@media (min-width: 900px) {
  .cols { grid-template-columns: 1fr 1fr; }
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 7px rgba(0,200,150,.7); }
  50% { box-shadow: 0 0 14px rgba(0,200,150,.9); }
}
.led.green.pulse { animation: pulse-green 2s ease-in-out infinite; }

/* profile dropdown */
.profile-menu { position: relative; margin-left: 8px; padding-left: 8px; border-left: 1px solid var(--border); }
.profile-btn {
  display: flex; align-items: center; position: relative;
  background: transparent; border: none; cursor: pointer; padding: 2px;
  border-radius: 50%; transition: opacity .12s;
}
.profile-btn:hover { opacity: .85; }
.profile-demo-dot {
  position: absolute; bottom: -1px; right: -1px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--amber); border: 2px solid #0d1015;
}
.profile-drop {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  background: #131820; border: 1px solid var(--border-bri); border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6); min-width: 240px; padding: 6px;
}
.profile-drop.open { display: block; }
.profile-drop-header { padding: 12px 12px 10px; }
.profile-drop-header-row { display: flex; align-items: center; gap: 11px; }
.profile-drop-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.profile-drop-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: none; color: var(--text-2);
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 9px 12px; border-radius: 6px; cursor: pointer; text-decoration: none;
}
.profile-drop-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
.profile-drop-item svg { flex: none; color: var(--muted); }
.profile-drop-item:hover svg { color: var(--text-2); }
.profile-drop-logout { color: var(--red); }
.profile-drop-logout svg { color: var(--red); }
.profile-drop-logout:hover { background: var(--red-dim); color: var(--red); }
.profile-drop-logout:hover svg { color: var(--red); }

/* ============================================================
   CHART TOOLBAR (TradingView-style)
   ============================================================ */
.tb-sep {
  display: block; width: 1px; height: 20px;
  background: rgba(139,148,158,.15); margin: 0 4px; flex-shrink: 0;
}
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 3px; height: 28px; min-width: 28px; padding: 0 6px;
  border-radius: 4px; font-size: 11.5px; color: #8B949E;
  background: none; border: none; cursor: pointer;
  white-space: nowrap; transition: background .1s, color .1s;
  font-family: var(--sans);
}
.tb-btn:hover { background: rgba(139,148,158,.12); color: #E6E8EB; }
.tb-btn.active { color: #00C896; background: rgba(0,200,150,.1); }
.ind-opt {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 14px; font-size: 12px; color: #CDD6E0;
  cursor: pointer; font-family: var(--sans);
}
.ind-opt:hover { background: rgba(139,148,158,.1); }
.asset-opt:hover { background: rgba(139,148,158,.1); color: var(--text); }
.asset-opt.active { color: var(--green); }
.ind-opt input[type="checkbox"] {
  width: 14px; height: 14px; accent-color: #00C896; cursor: pointer; margin: 0;
}
.ind-opt i {
  display: inline-block; width: 12px; height: 3px; border-radius: 2px; flex-shrink: 0;
}
#bt-candle-chart.hline-mode,
#bt-candle-chart.hline-mode canvas { cursor: crosshair !important; }

/* ============================================================
   BOTTOM TAB BAR (mobile nav)
   ============================================================ */

/* navigation progress bar */
#nav-progress {
  position: fixed; top: 0; left: 0; height: 2px; z-index: 999;
  background: var(--green); width: 0; opacity: 0;
  transition: none;
}
#nav-progress.loading {
  width: 70%; opacity: 1;
  transition: width 12s cubic-bezier(.08,.05,0,1), opacity .15s;
}
#nav-progress.done {
  width: 100%; opacity: 0;
  transition: width .15s ease, opacity .25s ease .15s;
}

.btm-nav {
  display: none; position: fixed; bottom: 0; left: 0; right: 0;
  background: #0C0E13; border-top: 1px solid var(--border);
  z-index: 100; align-items: stretch; justify-content: space-around;
  padding: 0 0 env(safe-area-inset-bottom);
}
.btm-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; flex: 1; padding: 10px 0 8px; background: none; border: none;
  color: var(--muted); font-size: 10px; font-family: var(--sans);
  text-decoration: none; cursor: pointer; transition: color .15s;
}
.btm-tab svg { width: 20px; height: 20px; }
.btm-tab.active { color: var(--green); }
.btm-more-panel {
  display: none; flex-direction: column; position: absolute; bottom: 100%;
  left: 0; right: 0; background: #131820; border-top: 1px solid var(--border-bri);
  border-radius: 12px 12px 0 0; box-shadow: 0 -8px 32px rgba(0,0,0,.5);
  padding: 8px 6px;
}
.btm-more-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  color: var(--text-2); font-size: 14px; font-family: var(--sans);
  text-decoration: none; border-radius: 8px; transition: background .12s;
}
.btm-more-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
.btm-more-item.active { color: var(--green); }
.btm-more-item svg { flex: none; }

/* ============================================================
   MOBILE (max-width: 767px)
   ============================================================ */
@media (max-width: 767px) {
  body { overflow: visible; }
  .app { height: auto; min-height: 100dvh; min-height: 100vh; }
  @supports (min-height: 100dvh) { .app { min-height: 100dvh; } }
  .main { min-height: 0; }
  .content { overflow-y: visible !important; padding: 12px 10px calc(68px + env(safe-area-inset-bottom)) !important; }
  .content.content-flush { padding: 6px 6px calc(68px + env(safe-area-inset-bottom)) !important; }
  .topbar { position: sticky; top: 0; z-index: 100; }
  .rail { display: none; }
  .btm-nav { display: flex; }

  /* Topbar: hide ticker, tighten */
  .topbar { gap: 10px; padding: 0 10px !important; }
  .topbar-ticker { display: none; }
  .balance-lbl { display: none; }
  .wordmark { font-size: 13px; }

  /* Profile dropdown */
  .profile-drop { right: -8px !important; min-width: 220px !important; max-width: calc(100vw - 16px); }

  /* Tables: horizontal scroll */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Position page */
  .ticker-price-wrap { display: flex; flex-direction: column; }
  .ticker-price-wrap #ticker-change { margin-left: 0 !important; font-size: 10px !important; }
  .pos-grid { display: flex !important; flex-direction: column !important; height: auto !important; gap: 6px !important; }
  .pos-grid > :nth-child(1) { order: 3; }
  .pos-grid > :nth-child(2) { order: 2; }
  .pos-right { display: contents !important; }
  .pos-bot-status { order: 1; margin-bottom: 0; }
  .pos-market-trades { order: 4; }
  .pos-chart-card { overflow: visible !important; }
  .pos-chart-card #position-chart { overflow: hidden; }
  .pos-cards-mobile { display: flex; flex-direction: column; gap: 10px; }
  #positions-table { display: none !important; }
  .tf-dropdown { left: auto !important; right: 0 !important; }
  .ticker-bar { padding: 8px 12px !important; gap: 8px !important; flex-wrap: wrap !important; }
  .ticker-bar > div[style*="width:1px"] { display: none; }
  .ticker-price-wrap { margin-left: auto; }
  .ticker-stats { width: 100%; flex-direction: row !important; justify-content: space-between; gap: 0 !important; }
  .ticker-bar { gap: 10px !important; flex-wrap: wrap; }
  #sym-menu { width: calc(100vw - 24px) !important; max-width: 340px; }

  /* Analytics */
  .analytics-grid { grid-template-columns: 1fr !important; }

  /* Backtester */
  .bt-grid { grid-template-columns: 1fr !important; }
  .bt-ticker { gap: 8px !important; padding: 6px 10px !important; z-index: 10 !important; }
  .bt-stats { gap: 4px !important; }
  .bt-grid > .card { position: static !important; }

  /* Hero stats */
  .hero-stat { padding: 16px 18px; }
  .hero-stat .v { font-size: 28px; }

  /* Page head */
  .page-title { font-size: 18px; }
}

/* ============================================================
   SMALL PHONE (max-width: 479px)
   ============================================================ */
@media (max-width: 479px) {
  .stat-row { grid-template-columns: 1fr !important; }

  .hero-stats { grid-template-columns: 1fr !important; }
  .hero-stat:nth-child(n) { border-right: none; border-bottom: 1px solid var(--border); }
  .hero-stat:last-child { border-bottom: none; }

  .stat .val { font-size: 20px; }
  .content { padding: 8px 8px calc(68px + env(safe-area-inset-bottom)) !important; }
  .page-title { font-size: 17px; }
  .hero-stat .v { font-size: 24px; }
}
