:root {
  color-scheme: light dark;
  font: 16px system-ui, sans-serif;
  color: var(--tg-theme-text-color, #eaf3f8);
  background: var(--tg-theme-bg-color, #121b25);
  --surface: var(--tg-theme-secondary-bg-color, #1c2936);
  --muted: var(--tg-theme-hint-color, #a4b7c9);
  --accent: var(--tg-theme-link-color, #69c5ff);
}
* { box-sizing: border-box; }
body { margin: 0; }
main { max-width: 860px; padding: 18px 14px 28px; margin: auto; }
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
h1 { font-size: clamp(1.35rem, 5vw, 2rem); margin: 0 0 12px; }
h2 { font-size: 1.05rem; margin: 14px 0 10px; }
.panel { padding: 12px; border-radius: 12px; background: var(--surface); }
.panel h2 { margin-top: 0; }
.filters, .charts, .metrics { display: grid; gap: 8px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.charts, #results > details { margin-top: 10px; }
.filters label { display: grid; gap: 5px; font-size: .85rem; min-width: 0; }
button, select, input {
  color: inherit; background: var(--tg-theme-bg-color, #121b25);
  border: 1px solid var(--muted); border-radius: 8px; padding: 8px; width: 100%; min-width: 0; min-height: 42px;
  font: inherit;
}
button { cursor: pointer; color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
header button { width: auto; }
#export, #send-report { align-self: end; }
#send-report { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; }
.table-wrap th, .table-wrap td { padding: .35rem .5rem; white-space: nowrap; }
.trade-link { border: 0; background: transparent; padding: 0; text-align: left; }
dialog { width: min(94vw, 42rem); max-height: 84dvh; padding: 1rem; color: inherit;
  background: var(--surface); border: 1px solid var(--muted); border-radius: 12px; }
dialog::backdrop { background: #101520b0; }
.hint { margin-bottom: 0; font-size: .84rem; }
.muted, dt { color: var(--muted); }
canvas { width: 100%; height: 170px; display: block; }
details + details { margin-top: 8px; }
summary { cursor: pointer; overflow-wrap: anywhere; }
dl { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 6px; font-size: .88rem; }
dd { margin: 0; overflow-wrap: anywhere; }
table { width: 100%; text-align: right; font-size: .82rem; margin-top: 8px; }
td:first-child, th:first-child { text-align: left; }
@media (min-width: 580px) { .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 579px) { .charts { grid-template-columns: 1fr; } }
