:root {
  --bg: #0b0d10;
  --bg-elev: #12161c;
  --bg-panel: #151a21;
  --bg-soft: #1a212b;
  --line: #27303c;
  --line-soft: #1f2732;
  --text: #e8edf4;
  --muted: #8b97a8;
  --faint: #5c6a7c;
  --buy: #22c55e;
  --buy-dim: rgba(34, 197, 94, 0.14);
  --sell: #f97316;
  --sell-dim: rgba(249, 115, 22, 0.14);
  --blue: #38bdf8;
  --blue-dim: rgba(56, 189, 248, 0.14);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.14);
  --purple: #a78bfa;
  --monthly: #38bdf8;
  --weekly: #a78bfa;
  --daily: #22c55e;
  --intra: #f59e0b;
  --rfto: #2dd4bf;
  --sidebar: 248px;
  --sidebar-collapsed: 72px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(56, 189, 248, 0.07), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(45, 212, 191, 0.05), transparent 50%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* Hide all scrollbars — scroll still works where overflow is set */
* {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
*::-webkit-scrollbar { width: 0; height: 0; display: none; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* —— Auth —— */
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, #141a22, #10151c);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}
.auth-brand .brand-logo-icon--auth {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 14px;
}
.auth-brand .brand-text--auth .brand-name {
  font-size: 1.55rem;
  line-height: 1.1;
}
.auth-brand .brand-text--auth .brand-sub {
  font-size: 0.78rem;
  margin-top: 2px;
}
.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 18px;
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 4px;
}
.auth-tab {
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.auth-tab.active {
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04);
}
.auth-form { display: grid; gap: 4px; }
.auth-form input {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
  margin-bottom: 10px;
  font-family: var(--mono);
  font-size: 0.9rem;
}
.auth-form input:focus { border-color: #3a4656; }
.auth-submit { width: 100%; margin-top: 6px; justify-content: center; }
.user-menu { position: relative; }
.user-menu .avatar {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  cursor: pointer;
}
.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 160px;
  background: #12171e;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  z-index: 30;
  box-shadow: 0 16px 40px rgba(0,0,0,0.35);
}
.user-dropdown-name {
  padding: 8px 10px 6px;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--mono);
}
.user-dropdown-item {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}
.user-dropdown-item:hover { background: var(--bg-soft); }

.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 0.22s ease;
}
.app.collapsed { grid-template-columns: var(--sidebar-collapsed) 1fr; }

/* —— Sidebar —— */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 12px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #0e1218 0%, #0b0d10 100%);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo-icon {
  flex-shrink: 0;
  border-radius: 12px;
  display: block;
  object-fit: cover;
}
.brand-logo-icon--sidebar {
  width: 44px;
  height: 44px;
}
.app.collapsed .brand-logo-icon--sidebar {
  width: 38px;
  height: 38px;
}
.brand-text { min-width: 0; }
.brand-name {
  font-weight: 700;
  letter-spacing: -0.03em;
  font-size: 1.28rem;
  line-height: 1.15;
}
.brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 1px;
}
.collapse-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  cursor: pointer;
  color: var(--muted);
  flex-shrink: 0;
}
.collapse-btn:hover { color: var(--text); }
.app.collapsed .brand-text,
.app.collapsed .nav-label,
.app.collapsed .nav-group,
.app.collapsed .chev,
.app.collapsed .tz,
.app.collapsed .dot,
.app.collapsed .nav-sub,
.app.collapsed .nav-sub-wrap,
.app.collapsed .nav-dropdown.open .nav-sub,
.app.collapsed .nav-dropdown.open .nav-sub-wrap,
.app.collapsed .webhook-pill .nav-label { display: none !important; }
.app.collapsed .nav-item { justify-content: center; padding: 12px; }
.app.collapsed .collapse-btn { margin: 0 auto; transform: rotate(180deg); }
.app.collapsed .brand-row { flex-direction: column; }
.app.collapsed .webhook-pill { justify-content: center; padding: 8px; }
.app.collapsed .nav-dropdown { overflow: hidden; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; overflow: hidden; }
.nav-group {
  margin: 12px 10px 6px;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--bg-soft); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(34, 197, 94, 0.18), rgba(34, 197, 94, 0.05));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.25);
}
.nav-item.has-sub .chev { margin-left: auto; font-size: 0.7rem; opacity: 0.7; }
.nav-dropdown.open .chev { transform: rotate(180deg); }
.nav-sub-wrap { position: relative; display: none; }
.nav-dropdown.open .nav-sub-wrap { display: block; }
.nav-sub {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 4px 8px 12px;
  max-height: 46vh;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.nav-sub-arrow {
  display: none;
  width: calc(100% - 8px);
  margin: 0 4px;
  text-align: center;
  border: 0;
  background: linear-gradient(180deg, rgba(14, 18, 24, 0.9), rgba(14, 18, 24, 0));
  color: var(--faint);
  cursor: pointer;
  padding: 4px 0 2px;
  font-size: 0.6rem;
  line-height: 1;
  border-radius: 6px;
}
.nav-sub-arrow.down { background: linear-gradient(0deg, rgba(14, 18, 24, 0.9), rgba(14, 18, 24, 0)); padding: 2px 0 4px; }
.nav-sub-arrow:hover { color: var(--text); }
.nav-sub-arrow.visible { display: block; }
.nav-sub-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
}
.nav-sub-btn:hover { background: var(--bg-soft); color: var(--text); }
.nav-sub-btn.active {
  color: var(--rfto);
  background: rgba(45, 212, 191, 0.1);
}
.nav-ico { width: 1.1rem; text-align: center; flex-shrink: 0; }
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); margin-left: auto;
  box-shadow: 0 0 8px var(--red);
}
.sidebar-foot { padding: 8px; display: grid; gap: 8px; }
.webhook-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 999px;
  background: var(--buy-dim); color: var(--buy);
  font-size: 0.78rem; font-weight: 600; width: fit-content;
}
.tz { font-size: 0.72rem; color: var(--faint); padding-left: 4px; }
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--buy); box-shadow: 0 0 10px var(--buy);
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* —— Topbar —— */
.main {
  min-width: 0;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(11, 13, 16, 0.78);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.search {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 12px;
  background: var(--bg-elev); border: 1px solid var(--line);
}
.search input { flex: 1; border: 0; outline: 0; background: transparent; }
.search input::placeholder { color: var(--faint); }
.search kbd {
  font-family: var(--mono); font-size: 0.68rem; color: var(--faint);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px;
}
.search-close { display: none; }
.search-toggle { display: none; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.ist-clock {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 1px;
  align-items: center;
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  min-width: 132px;
}
.ist-clock-label {
  grid-row: 1 / span 2;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--rfto);
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(45, 212, 191, 0.12);
}
.ist-clock strong {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: 0.02em;
}
.ist-clock-date {
  font-size: 0.68rem;
  color: var(--muted);
  font-weight: 600;
}

.mini-stats {
  display: flex; align-items: stretch; gap: 6px;
  padding: 4px; border-radius: 14px;
  background: rgba(18, 22, 28, 0.95); border: 1px solid var(--line-soft);
}
.mini-stat {
  display: flex; flex-direction: column; justify-content: center; gap: 2px;
  min-width: 58px; padding: 6px 12px; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid transparent;
  border-left: 3px solid transparent; cursor: pointer; text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.mini-stat:hover { transform: translateY(-1px); border-color: var(--line); }
.mini-stat.blue { border-left-color: var(--blue); }
.mini-stat.green { border-left-color: var(--buy); }
.mini-stat.orange { border-left-color: var(--sell); }
.mini-stat.red { border-left-color: var(--red); }
.mini-stat.active-stat { background: rgba(255,255,255,0.04); box-shadow: inset 0 0 0 1px var(--line); }
.mini-label {
  font-size: 0.58rem; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--faint); font-weight: 700;
}
.mini-stat strong { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; line-height: 1; }
.mini-stat.blue strong { color: var(--blue); }
.mini-stat.green strong { color: var(--buy); }
.mini-stat.orange strong { color: var(--sell); }
.mini-stat.red strong { color: var(--red); }
.live-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
  color: var(--buy); padding: 6px 10px; border-radius: 999px; background: var(--buy-dim);
}
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-elev); cursor: pointer;
}
.badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff;
  font-size: 0.65rem; font-weight: 700; display: grid; place-items: center;
}
.avatar {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 700; font-size: 0.8rem;
  background: linear-gradient(135deg, #1e293b, #334155); border: 1px solid var(--line);
}

/* —— Views —— */
.content { padding: 22px 24px 40px; display: none; gap: 16px; }
.content.view.active { display: grid; overflow: auto; flex: 1; min-height: 0; align-content: start; scrollbar-width: none; }
.page-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
}
.page-head.compact h1 { font-size: 1.3rem; margin: 0; }
.page-head h1 { margin: 0 0 4px; font-size: 1.55rem; letter-spacing: -0.03em; }
.page-head p { margin: 0; color: var(--muted); font-size: 0.88rem; }
.page-head .trade-count {
  font-family: var(--mono); font-size: 0.85rem; color: var(--muted);
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-elev);
}
.page-head .trade-count b { color: var(--text); }
.cat-chip-row { display: none; }
.chip-row, .tf-pills, .asset-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .pill, .tab {
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--muted);
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  font-size: 0.8rem; font-weight: 600;
}
.chip.active, .pill.active, .tab.active {
  color: #fff; background: rgba(34, 197, 94, 0.16); border-color: rgba(34, 197, 94, 0.45);
}
.filter-input {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px; min-width: 220px; outline: none;
}

/* Trade Desk — filters + compact single-line rows */
.desk-head { align-items: center; }
.desk-filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-top: -6px;
}
.desk-select {
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 0.8rem; min-width: 150px;
  outline: none; cursor: pointer;
}
.desk-search { min-width: 180px; flex: 1 1 180px; max-width: 280px; }
.desk-exec-pills { margin-left: auto; }
.desk-table-wrap table.desk-table { min-width: 1100px; }
.desk-table-wrap .desk-table th,
.desk-table-wrap .desk-table td {
  padding: 7px 10px;
  vertical-align: middle;
}
.desk-table-wrap .desk-table .nowrap { white-space: nowrap; }
.desk-table-wrap .desk-table .col-id {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--faint);
  font-size: 0.65rem;
}
.desk-table-wrap .kactions--compact {
  margin-top: 0;
  flex-wrap: nowrap;
  gap: 4px;
}
.desk-table-wrap .kactions--compact .tap-btn {
  width: 24px;
  height: 24px;
  font-size: 0.72rem;
  border-radius: 6px;
}
.desk-table-wrap .stage-pill,
.desk-table-wrap .tf-tag {
  white-space: nowrap;
}

.panel {
  background: var(--bg-panel); border: 1px solid var(--line-soft);
  border-radius: 16px; padding: 16px; min-width: 0;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px;
}
.panel-head.tight { margin-bottom: 10px; }
.panel-head h2 { margin: 0 0 4px; font-size: 1.02rem; letter-spacing: -0.02em; }
.panel-head p { margin: 0; color: var(--muted); font-size: 0.78rem; }

/* Trade Desk — Performance / P&L */
.pnl-panel { margin-bottom: 16px; }
.pnl-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.pnl-card {
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  border-radius: 12px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.pnl-card span {
  font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--faint); font-weight: 700;
}
.pnl-card strong {
  font-family: var(--mono); font-size: 1.15rem; font-weight: 700;
}
.pnl-card strong.pos { color: var(--buy); }
.pnl-card strong.neg { color: var(--red); }
.pnl-table-row-pos { color: var(--buy); }
.pnl-table-row-neg { color: var(--red); }
@media (max-width: 1400px) {
  .dash-layout { grid-template-columns: 1fr 220px; }
}
@media (max-width: 900px) {
  .pnl-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Dashboard layout */
.dash-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 14px;
  min-height: calc(100vh - 170px);
  align-items: stretch;
}
.signal-panel { display: flex; flex-direction: column; min-height: 560px; min-width: 0; overflow: hidden; }
.cat-empty, .nest-empty {
  flex: 1; display: grid; place-content: center; text-align: center;
  gap: 8px; color: var(--muted); padding: 48px 20px;
}
.nest-empty-ico { font-size: 2rem; opacity: 0.45; }
.cat-empty h2 { margin: 0; color: var(--text); font-size: 1.15rem; }
.cat-empty p { margin: 0; font-size: 0.88rem; }
.signal-body { flex: 1; display: flex; flex-direction: column; min-height: 0; gap: 12px; }

.rfto-banner {
  display: block;
  padding: 10px 14px; border-radius: 10px; width: 100%;
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.25);
  font-size: 0.84rem; color: var(--muted);
}
.rfto-banner strong { color: var(--rfto); font-weight: 700; }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Dashboard: kanban-by-timeframe board for the selected pair */
.dash-panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.dash-head-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto;
}
.col-add-head-wrap { position: relative; }
.col-add-head-btn {
  width: 36px; height: 36px; padding: 0; font-size: 1.25rem; font-weight: 400; line-height: 1;
  display: grid; place-items: center;
}
.pair-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0;
}
.pair-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -0.02em; }
.pair-head-cat { font-size: 0.76rem; color: var(--faint); }
.popout-btn { flex-shrink: 0; }

.dash-board {
  flex: 1; min-height: 0; min-width: 0; width: 100%;
  display: grid;
  gap: 14px;
  overflow-x: auto;
  overflow-y: visible;
  align-items: stretch;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.col {
  display: flex; flex-direction: column;
  min-width: 220px;
  background: var(--bg-soft); border: 1px solid var(--line-soft);
  border-radius: 12px; overflow: hidden; min-height: 280px;
}
.col-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft);
  font-size: 0.9rem;
}
.col-head-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.col.M .col-head { border-top: 3px solid var(--monthly); }
.col.W .col-head { border-top: 3px solid var(--weekly); }
.col.D .col-head { border-top: 3px solid var(--daily); }
.col.I .col-head { border-top: 3px solid var(--intra); }
.col.P .col-head { border-top: 3px solid var(--purple); }
.col-close {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line);
  background: transparent; color: var(--faint); cursor: pointer; font-size: 1rem; line-height: 1;
  display: grid; place-items: center; padding: 0;
}
.col-close:hover { color: var(--red); border-color: var(--red); background: var(--red-dim); }
.col-head .count { font-size: 0.72rem; color: var(--faint); white-space: nowrap; }

.col-add-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 30;
  min-width: 200px; max-height: 320px; overflow-y: auto;
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  padding: 6px;
  scrollbar-width: none;
}
.col-add-opt {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); cursor: pointer;
}
.col-add-opt:hover { background: var(--bg-soft); }
.col-add-opt strong { font-size: 0.85rem; }
.col-add-opt small { font-size: 0.68rem; color: var(--faint); }
.col-add-empty { padding: 12px; font-size: 0.78rem; color: var(--faint); text-align: center; }
.col-body {
  flex: 1; overflow-y: auto; padding: 10px;
  display: grid; gap: 8px; align-content: start;
  scrollbar-width: none;
}
.col-empty {
  color: var(--faint); font-size: 0.76rem; text-align: center;
  padding: 14px 8px;
}

.kcard {
  position: relative;
  border-radius: 10px; border: 1px solid var(--line-soft); background: var(--bg-soft);
  padding: 12px 14px; display: grid; gap: 8px;
  animation: riseIn 0.25s ease both;
}
.kcard.chained { border-color: rgba(45, 212, 191, 0.35); }
.chain-tag {
  position: absolute; top: -8px; right: 8px;
  background: var(--rfto); color: #04211d; font-size: 0.6rem; font-weight: 800;
  padding: 2px 7px; border-radius: 999px; letter-spacing: 0.03em;
}
.kcard-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 6px; flex-wrap: wrap; margin-bottom: 2px;
}
.kcard-top .side-buy, .kcard-top .side-sell { font-weight: 700; font-size: 0.88rem; }
.kdetail {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin-top: 4px;
}
.kdetail div { background: var(--bg-elev); border-radius: 7px; padding: 6px 8px; }
.kdetail span {
  display: block; font-size: 0.58rem; text-transform: uppercase;
  color: var(--faint); margin-bottom: 1px; font-family: var(--font);
}
.kdetail b { font-family: var(--mono); font-size: 0.82rem; font-weight: 600; }
.kmeta {
  display: flex; gap: 10px; flex-wrap: wrap;
  font-size: 0.72rem; color: var(--muted); margin-top: 2px;
}
.kmeta b { color: var(--text); font-weight: 600; }
.kmeta.chain-note { color: var(--rfto); }
.kid {
  margin-top: 4px; font-family: var(--mono); font-size: 0.62rem;
  color: var(--faint); word-break: break-all;
}
.kactions {
  display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap;
}
.tap-btn {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 0.85rem;
  display: grid; place-items: center; padding: 0;
}
.tap-btn.yes.active { background: var(--buy-dim); border-color: var(--buy); color: var(--buy); }
.tap-btn.no.active { background: var(--red-dim); border-color: var(--red); color: var(--red); }
.tap-btn:hover { border-color: #3a4656; color: var(--text); }
.exec-note { font-size: 0.72rem; color: var(--faint); }

/* Pop-out board window — minimal chrome, full kanban */
body.popout-mode { overflow: hidden; }
body.popout-mode .sidebar,
body.popout-mode .topbar,
body.popout-mode .bottom-nav,
body.popout-mode .collapse-btn { display: none !important; }
body.popout-mode .app,
body.popout-mode .app.collapsed { grid-template-columns: 1fr; }
body.popout-mode .main { height: 100vh; }
body.popout-mode .content.view.active {
  padding: 12px 16px; overflow: hidden; display: flex; flex-direction: column;
}
body.popout-mode .page-head,
body.popout-mode .cat-chip-row,
body.popout-mode .pair-rail,
body.popout-mode #dash-trade-count { display: none !important; }
body.popout-mode .dash-layout { grid-template-columns: 1fr; min-height: 0; flex: 1; }
body.popout-mode .signal-panel { min-height: 0; flex: 1; border: 0; background: transparent; }
body.popout-mode .signal-body { flex: 1; min-height: 0; }
body.popout-mode .dash-board {
  overflow-x: auto; min-height: 0;
}
body.popout-mode .col { min-height: calc(100vh - 120px); }
body.popout-mode .popout-btn { display: none !important; }

/* Pair rail */
.pair-rail {
  display: flex; flex-direction: column;
  max-height: calc(100vh - 170px);
  overflow: hidden;
}
.pair-rail-list {
  display: flex; flex-direction: column; gap: 8px;
  overflow: auto; flex: 1; scroll-snap-type: y mandatory;
}
.pair-chip {
  scroll-snap-align: start;
  display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center;
  width: 100%; text-align: left; padding: 12px;
  border-radius: 12px; border: 1px solid var(--line-soft);
  background: var(--bg-soft); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.pair-chip:hover { border-color: #3a4656; }
.pair-chip.active {
  border-color: rgba(45, 212, 191, 0.45);
  background: rgba(45, 212, 191, 0.08);
}
.pair-chip strong { display: block; font-size: 0.9rem; }
.pair-chip small { color: var(--muted); font-size: 0.72rem; }
.pair-chip .pc-meta {
  font-family: var(--mono); font-size: 0.65rem; color: var(--faint); text-align: right;
}
.pair-chip .pc-meta b { display: block; color: var(--blue); font-weight: 600; }

.sym-orb {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.62rem; font-weight: 800; background: #1e293b; border: 1px solid var(--line);
}
.sym-orb.FOREX { color: var(--blue); border-color: rgba(56,189,248,0.4); }
.sym-orb.METAL { color: #fbbf24; border-color: rgba(251,191,36,0.4); }
.sym-orb.CRYPTO { color: var(--sell); border-color: rgba(249,115,22,0.4); }
.sym-orb.STOCK { color: var(--purple); border-color: rgba(167,139,250,0.4); }
.sym-orb.INDEX { color: var(--buy); border-color: rgba(34,197,94,0.4); }

.stage-pill {
  font-size: 0.65rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; letter-spacing: 0.04em;
}
.stage-pill.ARMED { background: var(--blue-dim); color: var(--blue); }
.stage-pill.FILLED { background: rgba(167,139,250,0.16); color: var(--purple); }
.stage-pill.CLOSED { background: var(--buy-dim); color: var(--buy); }
.stage-pill.CANCELLED { background: var(--red-dim); color: var(--red); }
.tf-tag {
  font-size: 0.65rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 6px; width: fit-content;
}
.tf-tag.M { color: var(--monthly); background: rgba(56,189,248,0.12); }
.tf-tag.W { color: var(--weekly); background: rgba(167,139,250,0.12); }
.tf-tag.D { color: var(--daily); background: rgba(34,197,94,0.12); }
.tf-tag.I { color: var(--intra); background: rgba(245,158,11,0.12); }
.side-buy { color: var(--buy); }
.side-sell { color: var(--sell); }

/* Alerts */
.alert-feed { display: grid; gap: 10px; }
.alert-feed--page { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.alert-card {
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg-soft);
  padding: 12px 14px; display: grid; gap: 10px;
}
.alert-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.alert-pair { display: flex; align-items: center; gap: 10px; }
.alert-pair strong { display: block; font-size: 0.9rem; }
.alert-pair small { color: var(--muted); font-size: 0.72rem; }
.alert-levels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.lvl { background: rgba(0,0,0,0.22); border-radius: 8px; padding: 6px 8px; }
.lvl label {
  display: block; font-size: 0.6rem; color: var(--faint);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px;
}
.lvl b { font-family: var(--mono); font-size: 0.74rem; font-weight: 500; }
.alert-foot {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 0.72rem; color: var(--muted);
}

/* Tables */
.table-wrap { overflow: auto; border-radius: 12px; border: 1px solid var(--line-soft); scrollbar-width: none; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 900px; }
th {
  text-align: left; padding: 12px 14px; color: var(--faint); font-weight: 600;
  font-size: 0.68rem; letter-spacing: 0.06em; text-transform: uppercase;
  background: #10151c; border-bottom: 1px solid var(--line-soft); position: sticky; top: 0;
}
td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
.mono { font-family: var(--mono); font-size: 0.74rem; }
.empty { color: var(--muted); text-align: center; padding: 28px; }

.exec-pill {
  font-size: 0.68rem; font-weight: 700; padding: 4px 8px; border-radius: 999px;
}
.exec-pill.yes { background: var(--buy-dim); color: var(--buy); }
.exec-pill.no { background: var(--red-dim); color: var(--red); }
.exec-pill.pending { background: rgba(245,158,11,0.14); color: var(--intra); }
.confirm-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.confirm-btns button {
  border: 1px solid var(--line); background: var(--bg-elev);
  border-radius: 8px; padding: 5px 10px; font-size: 0.72rem; font-weight: 600; cursor: pointer;
}
.confirm-btns button.yes:hover { border-color: var(--buy); color: var(--buy); }
.confirm-btns button.no:hover { border-color: var(--red); color: var(--red); }
.confirm-btns button.active-yes { background: var(--buy-dim); color: var(--buy); border-color: var(--buy); }
.confirm-btns button.active-no { background: var(--red-dim); color: var(--red); border-color: var(--red); }
.confirm-btns .edit-toggle {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; padding: 4px 9px; font-size: 0.68rem; font-weight: 700; cursor: pointer;
}
.confirm-btns .edit-toggle:hover { color: var(--text); border-color: #3a4656; }
.confirm-btns .confirm-actions { display: none; gap: 6px; }
.confirm-btns.open .confirm-actions { display: flex; }

/* Stat drawer */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 40;
}
.stat-drawer {
  position: fixed; top: 0; right: 0; width: min(420px, 100%); height: 100vh;
  background: #10141a; border-left: 1px solid var(--line);
  z-index: 50; display: flex; flex-direction: column;
  box-shadow: -20px 0 60px rgba(0,0,0,0.4);
  animation: slideIn 0.22s ease;
}
@keyframes slideIn {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px; border-bottom: 1px solid var(--line-soft); flex-shrink: 0;
}
.drawer-head h2 { margin: 0 0 4px; font-size: 1.1rem; }
.drawer-head p { margin: 0; color: var(--muted); font-size: 0.8rem; }
.drawer-body { padding: 14px; overflow: auto; display: grid; gap: 10px; flex: 1; align-content: start; }
.drawer-item {
  border: 1px solid var(--line-soft); border-radius: 12px; padding: 12px;
  background: var(--bg-soft); display: flex; flex-direction: column; gap: 12px;
}
.drawer-item-top {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.drawer-item .alert-pair { flex: 1; min-width: 0; }
.drawer-item .stage-pill { flex-shrink: 0; margin-top: 2px; }
.drawer-pair-text { min-width: 0; }
.drawer-pair-text strong { display: block; font-size: 0.92rem; line-height: 1.25; }
.drawer-pair-text small {
  display: block; margin-top: 4px; color: var(--muted);
  font-size: 0.74rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-levels {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  margin: 0;
}
.drawer-levels > div {
  background: #0f1318; border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 8px 8px 9px; min-height: 0;
}
.drawer-levels span {
  display: block; font-size: 0.62rem; color: var(--faint);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; font-weight: 700;
}
.drawer-levels b {
  display: block; font-family: var(--mono); font-size: 0.8rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nowrap { white-space: nowrap; }
td.mono.nowrap { white-space: nowrap; }

/* Bottom tab bar (mobile only, see media query) */
.bottom-nav { display: none; }
.bn-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; flex: 1; color: var(--muted); font-size: 0.62rem; font-weight: 700;
  padding: 6px 2px; border-radius: 12px; min-height: 48px;
}
.bn-item .bn-ico { font-size: 1.2rem; line-height: 1; }
.bn-item.active { color: #fff; background: rgba(34, 197, 94, 0.14); }

/* Settings */
.settings-panel h2 { margin: 0 0 6px; font-size: 1.05rem; }
.settings-help, .settings-panel > p { margin: 0 0 14px; color: var(--muted); font-size: 0.85rem; }
.pin-row, .copy-row { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.pin-row input, .copy-row input {
  flex: 1; background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none; font-family: var(--mono); font-size: 0.82rem;
}
.pin-row input { max-width: 120px; letter-spacing: 0.35em; text-align: center; }
.settings-label {
  display: block; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--faint); margin-bottom: 6px; font-weight: 700;
}
.settings-actions { display: flex; align-items: center; gap: 12px; margin: 8px 0 18px; flex-wrap: wrap; }
.settings-status { font-size: 0.8rem; color: var(--rfto); }
.settings-error { color: var(--red); font-size: 0.82rem; }
.toggle-row {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.82rem; font-weight: 600; color: var(--muted); cursor: pointer;
}
.toggle-row input { width: 16px; height: 16px; accent-color: var(--buy); }
#telegram-settings { margin-top: 14px; }
#tg-bot-token, #tg-chat-id {
  flex: 1; width: 100%;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
  font-family: var(--mono); font-size: 0.82rem;
}
.tg-chat-list {
  display: grid; gap: 6px; margin: 0 0 12px;
}
.tg-chat-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  border: 1px solid var(--line); background: var(--bg-soft);
  border-radius: 10px; padding: 10px 12px; cursor: pointer;
}
.tg-chat-item:hover { border-color: #3a4656; }
.tg-chat-item strong { font-size: 0.85rem; }
.tg-chat-item span { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
#telegram-settings .settings-help {
  margin: 0 0 14px; font-size: 0.78rem; color: var(--faint); line-height: 1.4;
}

/* Telegram routing */
.route-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px;
}
.route-select {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none; font-size: 0.82rem;
}
.route-form input {
  flex: 1; min-width: 180px;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
  font-family: var(--mono); font-size: 0.82rem;
}
.route-list { display: grid; gap: 8px; margin-bottom: 10px; }
.route-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--line-soft); background: var(--bg-soft);
  border-radius: 10px; padding: 10px 12px;
}
.route-item .route-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.route-item .route-scope-badge {
  font-size: 0.62rem; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: rgba(56,189,248,0.14); color: var(--blue);
  flex-shrink: 0;
}
.route-item .route-scope-badge.symbol { background: rgba(167,139,250,0.16); color: var(--purple); }
.route-item .route-target { font-weight: 700; font-size: 0.85rem; }
.route-item .route-chat { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); }
.route-item .route-remove {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; padding: 5px 10px; font-size: 0.72rem; font-weight: 600; cursor: pointer; flex-shrink: 0;
}
.route-item .route-remove:hover { border-color: var(--red); color: var(--red); }
.route-empty { color: var(--muted); font-size: 0.82rem; padding: 10px 0; }

/* Categories admin */
.cat-list { display: grid; gap: 10px; margin-top: 4px; }
.cat-card {
  border: 1px solid var(--line-soft); background: var(--bg-soft);
  border-radius: 12px; overflow: hidden;
}
.cat-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; cursor: pointer; user-select: none;
}
.cat-card-head:hover { background: rgba(255,255,255,0.02); }
.cat-card-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cat-card-title .cat-caret { font-size: 0.7rem; color: var(--muted); transition: transform 0.15s ease; flex-shrink: 0; }
.cat-card.open .cat-caret { transform: rotate(90deg); }
.cat-card-title strong { font-size: 0.9rem; }
.cat-card-title .cat-count { font-size: 0.72rem; color: var(--muted); }
.cat-card-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.cat-icon-btn {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 8px; width: 26px; height: 26px; font-size: 0.75rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cat-icon-btn:hover { border-color: var(--blue); color: var(--blue); }
.cat-icon-btn.danger:hover { border-color: var(--red); color: var(--red); }
.cat-card-body { padding: 0 12px 12px; display: none; }
.cat-card.open .cat-card-body { display: block; }
.cat-rename-row { display: flex; gap: 8px; margin-bottom: 10px; }
.cat-rename-row input {
  flex: 1; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 0.8rem; outline: none;
}
.cat-symbols { display: grid; gap: 6px; margin-bottom: 10px; }
.cat-symbol-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1px solid var(--line-soft); background: var(--bg);
  border-radius: 8px; padding: 7px 10px;
}
.cat-symbol-row .sym-info { display: flex; flex-direction: column; min-width: 0; }
.cat-symbol-row .sym-ticker { font-family: var(--mono); font-weight: 700; font-size: 0.8rem; }
.cat-symbol-row .sym-name { font-size: 0.72rem; color: var(--muted); }
.cat-symbol-row .sym-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.cat-symbol-row select {
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 6px; font-size: 0.72rem; outline: none; max-width: 120px;
}
.cat-add-symbol { display: flex; gap: 6px; flex-wrap: wrap; }
.cat-add-symbol input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: 0.78rem; outline: none;
}
.cat-add-symbol input.sym-ticker-input { width: 100px; font-family: var(--mono); text-transform: uppercase; }
.cat-add-symbol input.sym-name-input { flex: 1; min-width: 120px; }
.cat-add-symbol select { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; font-size: 0.78rem; outline: none; }
.cat-empty { color: var(--muted); font-size: 0.78rem; padding: 4px 0 10px; }

.uncat-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.uncat-section h3 { margin: 0 0 2px; font-size: 0.9rem; }
.uncat-list { display: grid; gap: 6px; margin-top: 10px; }
.uncat-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  border: 1px solid var(--line-soft); background: var(--bg-soft);
  border-radius: 8px; padding: 7px 10px;
}
.uncat-row .sym-ticker { font-family: var(--mono); font-weight: 700; font-size: 0.8rem; }
.uncat-row .uncat-assign { display: flex; align-items: center; gap: 6px; }
.uncat-row select {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 5px 8px; font-size: 0.75rem; outline: none;
}

.chain-badge {
  color: rgb(45, 212, 191); font-weight: 700; font-size: 0.72rem; white-space: nowrap;
}

/* Small "?" info tooltip, e.g. next to the Performance heading */
.info-dot {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; border-radius: 50%; background: var(--bg-elev); border: 1px solid var(--line);
  color: var(--muted); font-size: 0.62rem; font-weight: 800; cursor: help; vertical-align: middle; margin-left: 4px;
}
.info-dot .info-tip {
  display: none; position: absolute; z-index: 20; top: 130%; left: 0;
  width: 260px; max-width: 70vw; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 0.72rem; font-weight: 400; line-height: 1.5;
  color: var(--text); box-shadow: 0 12px 28px rgba(0,0,0,0.4); white-space: normal; cursor: auto;
}
.info-dot:hover .info-tip, .info-dot:focus .info-tip { display: block; }
.btn {
  border: 1px solid var(--line); background: var(--bg-soft);
  padding: 9px 14px; border-radius: 10px; cursor: pointer;
  font-weight: 600; font-size: 0.85rem;
}
.btn.sm { padding: 6px 10px; font-size: 0.78rem; }
.btn.ghost:hover { border-color: #3a4656; }
.btn.primary {
  background: linear-gradient(180deg, #2dd46a, #16a34a);
  border-color: transparent; color: #04140a;
}
.alert-foot .confirm-btns {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.alert-foot .exec-pill { margin-right: 2px; }


@media (max-width: 1100px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .dash-layout { grid-template-columns: 1fr; }
  .pair-rail { max-height: 280px; order: -1; }
  .mini-stats { width: 100%; }
  .alert-levels { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .content, .topbar { padding-left: 14px; padding-right: 14px; }
  .mini-stat { min-width: 0; flex: 1; }
}

/* ============ Phone layout (<=768px) ============ */
@media (max-width: 768px) {
  body { overflow-x: hidden; }

  /* App shell: hide sidebar entirely, use bottom tab bar instead */
  .sidebar { display: none; }
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .collapse-btn { display: none; }

  .bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    gap: 2px;
    background: rgba(11, 13, 16, 0.94);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line-soft);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  }
  .content { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }

  /* Topbar: collapse search into an icon-triggered overlay */
  .topbar { padding: 10px 14px; gap: 10px; }
  .search-toggle {
    display: grid; place-items: center; width: 40px; height: 40px; flex-shrink: 0;
    border-radius: 10px; border: 1px solid var(--line); background: var(--bg-elev);
    cursor: pointer; font-size: 1rem; color: var(--muted);
  }
  .search { display: none; }
  .search.open {
    display: flex; position: fixed; inset: 0; z-index: 60;
    max-width: none; border-radius: 0; border: 0; padding: 16px;
    background: var(--bg);
  }
  .search.open kbd { display: none; }
  .search-close {
    display: block; margin-left: 8px; background: transparent; border: 0;
    color: var(--muted); font-size: 1.15rem; cursor: pointer; padding: 6px;
  }
  .ist-clock { min-width: 0; padding: 6px 10px; }
  .ist-clock strong { font-size: 0.92rem; }
  .mini-stats { order: 3; width: 100%; }

  /* Dashboard: horizontal category chips + horizontal pair rail */
  .cat-chip-row {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 2px;
  }
  .cat-chip-row .chip { flex: 0 0 auto; }
  .dash-layout { grid-template-columns: 1fr; min-height: auto; }
  .pair-rail { order: -1; max-height: none; }
  .pair-rail-list {
    flex-direction: row; overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory; padding-bottom: 4px;
  }
  .pair-chip { min-width: 230px; flex: 0 0 auto; }
  .signal-panel { min-height: 0; }
  .dash-board {
    grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 82vw;
    scroll-snap-type: x mandatory; padding-bottom: 4px;
  }
  .col { scroll-snap-align: start; }

  /* Recent Alerts cards */
  .alert-feed--page { grid-template-columns: 1fr; }
  .alert-levels { grid-template-columns: repeat(2, 1fr); }

  /* Tables -> stacked cards */
  .table-wrap { border: 0; overflow: visible; border-radius: 0; }
  table { min-width: 0; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr {
    background: var(--bg-soft); border: 1px solid var(--line-soft);
    border-radius: 12px; margin-bottom: 10px; padding: 8px 12px;
  }
  td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 2px; border-bottom: 1px dashed var(--line-soft); text-align: right;
  }
  td:last-child { border-bottom: 0; }
  td::before {
    content: attr(data-label); color: var(--faint); font-size: 0.64rem;
    font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    text-align: left; flex-shrink: 0; margin-right: 10px;
  }
  td.empty { text-align: center; padding: 20px; }
  td.empty::before { content: none; }
  td.td-actions { flex-direction: column; align-items: flex-start; gap: 8px; }
  td.td-actions::before { margin-bottom: 2px; }

  /* Performance / P&L */
  .pnl-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pnl-pills { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .pnl-pills .pill { flex-shrink: 0; }

  /* Stat drawer becomes a bottom sheet */
  .stat-drawer {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%;
    height: min(82vh, 640px);
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.22s ease;
  }
  .drawer-levels { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  /* Settings & auth */
  .copy-row { flex-wrap: wrap; }
  .copy-row input { width: 100%; }
  .settings-actions { gap: 10px; }
  .filter-input { width: 100%; min-width: 0; }
  .desk-filters { align-items: stretch; }
  .desk-select, .desk-search { width: 100%; max-width: none; min-width: 0; }
  .desk-exec-pills { margin-left: 0; width: 100%; }
  .page-head { align-items: stretch; }

  /* Prevent iOS auto-zoom on focus */
  .auth-form input, #tg-bot-token, #tg-chat-id, .filter-input, .search input, .pin-row input {
    font-size: 16px;
  }
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 420px) {
  .alert-levels { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .pnl-summary { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 22px 18px 20px; }
}
