/* AxiomRSI panel — dark trading theme, RTL. Green = profit, red = loss. */

@font-face {
  font-family: "Vazirmatn";
  src: url("/fonts/Vazirmatn-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0a0e13;
  --bg-2: #0e131a;
  --panel: #121922;
  --panel-2: #18212c;
  --panel-3: #1f2a37;
  --border: #233041;
  --border-2: #2e3d52;
  --text: #e7edf4;
  --muted: #8a97a8;
  --faint: #5d6a7b;
  --pos: #22c55e;
  --pos-soft: rgba(34, 197, 94, 0.13);
  --neg: #f05252;
  --neg-soft: rgba(240, 82, 82, 0.13);
  --warn: #f5a524;
  --warn-soft: rgba(245, 165, 36, 0.13);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.13);
  --violet: #a78bfa;
  --accent: #4f8cff;
  --accent-2: #3b74e0;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --side-w: 232px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Vazirmatn", Tahoma, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.35; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: rgba(79, 140, 255, 0.35); }

/* numbers: always left-to-right inside the RTL page, tabular digits */
.num {
  direction: ltr;
  unicode-bidi: isolate;
  display: inline-block;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.info { color: var(--info); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.bold { font-weight: 700; }
.nowrap { white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- layout ---------- */

.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  min-height: 100vh;
}
.topbar { display: none; }
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 12px 14px;
  background: var(--bg-2);
  border-inline-end: 1px solid var(--border);
  overflow-y: auto;
}
.brand {
  color: var(--text);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.2px;
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none !important;
}
.brand-side { padding: 0 10px 12px; border-bottom: 1px solid var(--border); flex-direction: column; gap: 0; }
.brand-sub { color: var(--muted); font-weight: 500; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  text-decoration: none;
}
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.active { background: var(--panel-2); color: var(--text); box-shadow: inset -3px 0 0 var(--accent); }
.nav-ico { width: 18px; text-align: center; opacity: 0.8; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 4px 0; border-top: 1px solid var(--border); }
.conn { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; padding: 0 8px; }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; box-shadow: 0 0 0 3px var(--warn-soft); }
.conn-dot.ok { background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.conn-dot.bad { background: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.scrim { display: none; }

.main { padding: 20px 26px 56px; min-width: 0; outline: none; }
.page { display: flex; flex-direction: column; gap: 16px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.spacer { flex: 1; }

.loading { color: var(--muted); padding: 28px 4px; }
.loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-inline-end: 8px;
  vertical-align: -2px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cards ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.card-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.card-h h2 { display: flex; align-items: center; gap: 8px; }
.card-h .count { color: var(--muted); font-weight: 500; font-size: 13px; }
.card-flush { padding: 0; }
.card-flush > .card-h { padding: 14px 16px 0; }
.card-danger { border-color: rgba(240, 82, 82, 0.45); }
.card-danger h2 { color: var(--neg); }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.kpi {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-width: 0;
}
.kpi-label { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 21px; font-weight: 700; margin-top: 2px; line-height: 1.3; }
.kpi-sub { color: var(--muted); font-size: 12px; margin-top: 2px; min-height: 18px; }
.kpi-value .num { font-variant-numeric: tabular-nums; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  max-width: 100%;
}
.chip b { color: var(--text); font-weight: 600; }
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.chip.nodot::before { display: none; }
.chip.ok::before { background: var(--pos); }
.chip.bad::before { background: var(--neg); }
.chip.warn::before { background: var(--warn); }
.chip.info::before { background: var(--info); }
.chip.bad { border-color: rgba(240, 82, 82, 0.4); }
.chip.warn { border-color: rgba(245, 165, 36, 0.4); }

.badge {
  display: inline-block;
  padding: 0 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 19px;
  white-space: nowrap;
  background: var(--panel-3);
  color: var(--muted);
  vertical-align: middle;
}
.badge.pos { background: var(--pos-soft); color: var(--pos); }
.badge.neg { background: var(--neg-soft); color: var(--neg); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.violet { background: rgba(167, 139, 250, 0.14); color: var(--violet); }

/* phase colours */
.ph-watch { background: var(--panel-3); color: var(--muted); }
.ph-ready { background: var(--info-soft); color: var(--info); }
.ph-buying, .ph-selling { background: var(--warn-soft); color: var(--warn); }
.ph-position { background: var(--pos-soft); color: var(--pos); }
.ph-done { background: rgba(167, 139, 250, 0.14); color: var(--violet); }
.ph-expired, .ph-removed { background: var(--panel-3); color: var(--faint); }

/* ---------- buttons and inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none !important;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--panel-3); border-color: var(--faint); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: transparent; border-color: rgba(240, 82, 82, 0.55); color: var(--neg); }
.btn-danger:hover { background: var(--neg-soft); border-color: var(--neg); }
.btn-danger-solid { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-danger-solid:hover { background: #d63c3c; }
.btn-warn { background: transparent; border-color: rgba(245, 165, 36, 0.55); color: var(--warn); }
.btn-warn:hover { background: var(--warn-soft); }
.btn-ok { background: transparent; border-color: rgba(34, 197, 94, 0.55); color: var(--pos); }
.btn-ok:hover { background: var(--pos-soft); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { color: var(--text); }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.burger, .burger::before, .burger::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  position: relative;
}
.burger::before, .burger::after { content: ""; position: absolute; inset-inline-start: 0; }
.burger::before { top: -6px; }
.burger::after { top: 6px; }

.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
}
.seg button + button { border-inline-start: 1px solid var(--border-2); }
.seg button.on { background: var(--panel-3); color: var(--text); }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }

.input, select.input, textarea.input, .field-ctl input[type="number"], .field-ctl select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}
textarea.input { resize: vertical; min-height: 96px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.input:focus, .field-ctl input:focus, .field-ctl select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.2); }
.input::placeholder, textarea::placeholder { color: var(--faint); }
/* address boxes are left-to-right, but their Persian placeholder reads right-to-left */
.input[dir="ltr"]:placeholder-shown { direction: rtl; text-align: right; font-family: inherit; }
input[type="number"] { direction: ltr; text-align: left; }
input[type="datetime-local"] { direction: ltr; color-scheme: dark; }
.input-sm { padding: 5px 9px; font-size: 13px; }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }

/* switch */
input.switch {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: var(--panel-3);
  border: 1px solid var(--border-2);
  position: relative;
  cursor: pointer;
  flex: none;
  margin: 0;
  transition: background 0.15s;
}
input.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: right 0.15s, background 0.15s;
}
input.switch:checked { background: var(--accent); border-color: var(--accent); }
input.switch:checked::after { right: 20px; background: #fff; }

/* ---------- alerts, toasts, dialogs ---------- */

.alert { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel-2); font-size: 13px; }
.alert-error { border-color: rgba(240, 82, 82, 0.45); background: var(--neg-soft); color: #ffc9c9; }
.alert-warn { border-color: rgba(245, 165, 36, 0.45); background: var(--warn-soft); color: #ffe2b0; }
.alert-ok { border-color: rgba(34, 197, 94, 0.45); background: var(--pos-soft); color: #c6f6d5; }
.alert-info { border-color: rgba(96, 165, 250, 0.4); background: var(--info-soft); color: #cfe3ff; }

.toasts {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-inline-start: 4px solid var(--info);
  box-shadow: var(--shadow);
  font-size: 13px;
  animation: toast-in 0.18s ease-out;
  word-break: break-word;
}
.toast.ok { border-inline-start-color: var(--pos); }
.toast.error { border-inline-start-color: var(--neg); }
.toast.warn { border-inline-start-color: var(--warn); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

dialog.dlg {
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  padding: 18px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
dialog.dlg::backdrop { background: rgba(3, 6, 10, 0.65); }
.dlg h3 { margin-bottom: 10px; }
.dlg-body { color: var(--muted); font-size: 13.5px; margin-bottom: 16px; word-break: break-word; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
.table-wrap.tall { max-height: 560px; overflow-y: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 8px 10px; text-align: start; white-space: nowrap; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 1;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th.sorted-asc::after { content: " ▲"; font-size: 9px; }
.tbl th.sorted-desc::after { content: " ▼"; font-size: 9px; }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tbl tr.selected td { background: rgba(79, 140, 255, 0.09); }
.tbl td.empty { text-align: center; color: var(--muted); padding: 22px 10px; white-space: normal; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--border-2); border-bottom: 0; background: var(--panel-2); }
.tbl td.wrap { white-space: normal; min-width: 220px; }
.tbl td.actions { width: 1%; }
.tbl .sym { font-weight: 700; color: var(--text); }
.tbl .sym:hover { color: var(--info); }
.tbl .sub { display: block; color: var(--faint); font-size: 11px; line-height: 1.3; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.card-flush .table-wrap { border-radius: 0 0 var(--radius) var(--radius); }
.card-flush .tbl th:first-child, .card-flush .tbl td:first-child { padding-inline-start: 16px; }
.card-flush .tbl th:last-child, .card-flush .tbl td:last-child { padding-inline-end: 16px; }

.rsi-hit { color: var(--pos); font-weight: 700; }
.rsi-near { color: var(--warn); font-weight: 700; }
.rsi-high { color: var(--neg); }

/* key/value lists */
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: left; direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere; }
.kv dd.rtl { direction: rtl; text-align: left; }
.kv .sep { grid-column: 1 / -1; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---------- dashboard ---------- */

.status-card { display: flex; flex-direction: column; gap: 10px; }
.rules { color: var(--muted); font-size: 12.5px; line-height: 1.8; }
.rules b { color: var(--text); font-weight: 600; }

.feed { list-style: none; margin: 0; padding: 0; max-height: 460px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 4px 10px; align-items: baseline; padding: 8px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed li:last-child { border-bottom: 0; }
.feed li.fresh { animation: fresh 2.5s ease-out; }
@keyframes fresh { from { background: rgba(79, 140, 255, 0.16); } to { background: transparent; } }
.feed .t { color: var(--faint); font-size: 12px; }
.feed .txt { color: var(--text); overflow-wrap: anywhere; }
.feed .txt a { font-weight: 700; margin-inline-end: 6px; }
.feed-empty { color: var(--muted); padding: 12px 2px; }

.add-results { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.add-results li { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; padding: 6px 10px; background: var(--panel-2); border-radius: var(--radius-sm); }
.add-results .addr { font-family: var(--mono); font-size: 12px; color: var(--muted); direction: ltr; unicode-bidi: isolate; }

/* ---------- charts ---------- */

.chart-wrap { position: relative; direction: ltr; }
.chart { width: 100%; direction: ltr; position: relative; }
.chart-equity { height: 280px; }
.chart-main { height: 400px; }
.chart-rsi { height: 150px; border-top: 1px solid var(--border); }
.chart-day { height: 240px; }
.chart-legend {
  position: absolute;
  top: 6px;
  left: 8px;
  z-index: 3;
  pointer-events: none;
  font-size: 11.5px;
  font-family: var(--mono);
  color: var(--muted);
  background: rgba(10, 14, 19, 0.72);
  padding: 2px 8px;
  border-radius: 5px;
  direction: ltr;
  text-align: left;
  max-width: calc(100% - 100px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-legend b { color: var(--text); font-weight: 600; }
.chart-legend .lg-i { white-space: nowrap; }
.chart-legend .pos { color: var(--pos); }
.chart-legend .neg { color: var(--neg); }
.chart-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); height: 160px; border: 1px dashed var(--border-2); border-radius: var(--radius-sm); }
.chart-toolbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.legend-keys { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; color: var(--muted); }
.legend-keys span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-inline-end: 5px; vertical-align: -1px; background: currentColor; }
.lk-buy { color: var(--pos); }
.lk-sell { color: var(--neg); }
.lk-skip { color: #8a97a8; }
.lk-entry { color: var(--info); }
.lk-ready { color: var(--violet); }

/* bar lists (distribution, funnel, fees) */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 120px minmax(0, 1fr) 72px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .lbl { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .val { text-align: left; direction: ltr; font-variant-numeric: tabular-nums; }
.bar-track { height: 14px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--info); border-radius: 4px; min-width: 2px; }
.bar-fill.pos { background: var(--pos); }
.bar-fill.neg { background: var(--neg); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.faint { background: var(--faint); }
.bar-fill.violet { background: var(--violet); }

.hist { display: flex; align-items: flex-end; gap: 4px; height: 200px; padding: 0 2px; direction: ltr; }
.hist-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.hist-bar { width: 100%; max-width: 46px; border-radius: 4px 4px 0 0; background: var(--info); min-height: 2px; }
.hist-bar.pos { background: var(--pos); }
.hist-bar.neg { background: var(--neg); }
.hist-count { font-size: 11px; color: var(--text); margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.hist-axis { display: flex; gap: 4px; direction: ltr; padding: 4px 2px 0; border-top: 1px solid var(--border); }
.hist-axis span { flex: 1; text-align: center; font-size: 10.5px; color: var(--muted); min-width: 0; overflow: hidden; white-space: nowrap; }

/* ---------- token page ---------- */

.tok-head { display: flex; flex-direction: column; gap: 10px; }
.tok-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.tok-title h1 { font-size: 24px; overflow-wrap: anywhere; }
.tok-title .name { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.mint-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mint { font-family: var(--mono); font-size: 12.5px; color: var(--muted); direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere; background: var(--bg-2); border: 1px solid var(--border); border-radius: 6px; padding: 2px 8px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; }
.quick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.quick .q { background: var(--panel-2); border-radius: var(--radius-sm); padding: 8px 10px; min-width: 0; }
.quick .q-l { color: var(--muted); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quick .q-v { font-weight: 700; font-size: 15px; }
.big-pl { font-size: 26px; font-weight: 800; }

/* ---------- settings ---------- */

.settings-group { display: flex; flex-direction: column; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 6px 20px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.field:last-child { border-bottom: 0; }
.field.dirty { background: linear-gradient(to left, rgba(79, 140, 255, 0.08), transparent 60%); box-shadow: inset -3px 0 0 var(--accent); padding-inline-start: 10px; margin-inline-start: -10px; padding-inline-end: 0; }
.field.has-err .field-ctl input, .field.has-err .field-ctl select { border-color: var(--neg); }
.field-label { font-weight: 600; display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.field-help { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.field-ctl { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.field-ctl .unit { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 34px; }
.field-range { grid-column: 2; color: var(--faint); font-size: 11px; text-align: left; margin-top: -4px; }
.field-err { grid-column: 1 / -1; color: var(--neg); font-size: 12.5px; }
.field-err:empty { display: none; }
.applies-now { background: var(--pos-soft); color: var(--pos); }
.applies-new { background: var(--info-soft); color: var(--info); }
.applies-reset { background: var(--warn-soft); color: var(--warn); }
.savebar {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow);
}
.savebar .msg { flex: 1; color: var(--muted); font-size: 13px; min-width: 160px; }
.danger-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.danger-row .input { max-width: 220px; font-family: var(--mono); }

/* ---------- backtest ---------- */

.bt-rows { display: flex; flex-direction: column; gap: 8px; }
.bt-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 230px auto; gap: 8px; align-items: center; }
.bt-row .idx { color: var(--faint); font-size: 12px; text-align: center; }
.bt-row .input { font-size: 13px; }
.bt-row .addr { direction: ltr; text-align: left; font-family: var(--mono); font-size: 12.5px; }
.bt-overrides { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-2); }
.bt-overrides > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.bt-overrides > summary::-webkit-details-marker { display: none; }
.bt-overrides > summary::before { content: "◂"; color: var(--muted); transition: transform 0.15s; display: inline-block; }
.bt-overrides[open] > summary::before { transform: rotate(-90deg); }
.bt-overrides .body { padding: 0 14px 10px; }
.progress { height: 10px; background: var(--panel-2); border-radius: 999px; overflow: hidden; direction: ltr; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--info)); border-radius: 999px; transition: width 0.4s; }
.progress.indeterminate > span { width: 30% !important; animation: indet 1.2s ease-in-out infinite; }
@keyframes indet { 0% { margin-left: -30%; } 100% { margin-left: 100%; } }

/* ---------- logs ---------- */

.logbox {
  height: calc(100vh - 230px);
  min-height: 320px;
  overflow: auto;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  direction: ltr;
  text-align: left;
}
.logline { padding: 0 12px; white-space: pre-wrap; word-break: break-word; }
.logline:hover { background: rgba(255, 255, 255, 0.03); }
.logline .lt { color: var(--faint); margin-right: 8px; }
.logline.l-err { color: #ff9b9b; }
.logline.l-trade { color: #9be8b4; }
.logline.l-panel { color: #a9c9ff; }
.logline.l-warn { color: #ffd08a; }
.logline.fresh { animation: fresh 2s ease-out; }

/* ---------- login ---------- */

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; background: radial-gradient(ellipse at top, #121b27 0%, var(--bg) 60%); }
.login-wrap { width: 100%; max-width: 380px; }
.login-card { display: flex; flex-direction: column; gap: 12px; padding: 26px 22px; }
.login-brand { font-weight: 800; font-size: 18px; display: flex; gap: 8px; align-items: baseline; }
.login-title { font-size: 16px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }

/* ---------- responsive ---------- */

@media (max-width: 1180px) {
  .grid-main-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 10px 16px;
    background: rgba(14, 19, 26, 0.94);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand { flex: 1; font-size: 16px; }
  .side {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: min(280px, 84vw);
    height: auto;
    z-index: 60;
    transform: translateX(105%);
    /* closed: hidden from Tab and screen readers once it has slid out */
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
    box-shadow: var(--shadow);
  }
  .side.open { transform: none; visibility: visible; transition: transform 0.2s ease; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(3, 6, 10, 0.6); }
  .main { padding: 14px 16px 48px; }
  .toasts { top: 66px; }
  .field { grid-template-columns: minmax(0, 1fr); }
  .field-ctl { justify-content: flex-start; }
  .field-range { grid-column: 1; text-align: right; }
}
@media (max-width: 640px) {
  body { font-size: 13.5px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 11px; }
  .kpi-value { font-size: 17px; }
  .card { padding: 12px; }
  .card-flush { padding: 0; }
  .card-flush > .card-h { padding: 12px 12px 0; }
  .chart-main { height: 290px; }
  .chart-rsi { height: 120px; }
  .chart-equity { height: 220px; }
  .bt-row { grid-template-columns: 22px minmax(0, 1fr) auto; }
  .bt-row .start { grid-column: 2 / 3; }
  .bar-row { grid-template-columns: 92px minmax(0, 1fr) 56px; gap: 6px; }
  .tok-title h1 { font-size: 20px; }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .logbox { height: calc(100vh - 260px); }
  .hist-axis span { font-size: 9.5px; }
  /* the candle legend wraps instead of being cut off */
  .chart-legend { white-space: normal; text-overflow: clip; line-height: 1.35; font-size: 10.5px; }
  .chart-legend .lg-date { display: block; }
}
