:root {
  color-scheme: dark;
  --page: #101822;
  --header: #141e2a;
  --surface: #192532;
  --inset: #141f2b;
  --stroke: #2b3b4c;
  --text: #f1f5fa;
  --muted: #a4b5c8;
  --accent: #97bdff;
  --positive: #78d8b0;
  --negative: #ffaaa7;
  --warning: #f2c486;
  --equity-line: #8fbaff;
  --closed-line: #c0a8f6;
  --drawdown-line: #ff9d93;
  --long-line: #78d8b0;
  --short-line: #f2c486;
  font-family: "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--page);
  font-synthesis: none;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body { margin: 0; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: clamp(1.9rem, 3vw, 2.65rem); font-weight: 650; letter-spacing: -.045em; line-height: 1.15; }
h2 { font-size: 1.05rem; font-weight: 650; }
p { line-height: 1.55; }
small, dt { color: var(--muted); font-size: .82rem; }
a { color: var(--accent); text-underline-offset: 4px; }
button, input { font: inherit; }
button {
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: #142236;
  cursor: pointer;
  font-size: .86rem;
  font-weight: 650;
  min-height: 36px;
}
button:hover { filter: brightness(1.12); }
button:disabled { opacity: .5; cursor: default; }
button.secondary { background: var(--inset); border-color: #40536a; color: var(--text); }
button.danger { background: var(--negative); color: #351b1c; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.site-header { background: var(--header); border-bottom: 1px solid var(--stroke); }
.header-inner, main { width: min(100% - 64px, 1360px); margin-inline: auto; }
.header-inner { display: flex; min-height: 65px; align-items: center; gap: 36px; }
.brand { display: inline-flex; align-items: center; gap: 6px; color: var(--text); font-size: 1.13rem; font-weight: 720; text-decoration: none; white-space: nowrap; letter-spacing: -.025em; }
.brand span { font-weight: 450; color: #c4d1e1; }
.brand-mark {
  display: inline-block;
  position: relative;
  width: 27px;
  height: 27px;
  margin-right: 4px;
  border: 1px solid #567fb2;
  border-radius: 7px;
  background: #254367;
}
.brand-mark::before {
  content: "";
  position: absolute;
  width: 14px;
  height: 12px;
  top: 7px;
  left: 6px;
  background: var(--accent);
  clip-path: polygon(0 64%, 33% 37%, 54% 56%, 100% 0, 100% 38%, 57% 93%, 34% 73%, 0 100%);
}
.site-nav { display: flex; align-self: stretch; gap: 24px; }
.site-nav a { display: grid; align-items: center; border-bottom: 2px solid transparent; color: var(--muted); text-decoration: none; font-size: .9rem; }
.site-nav a:hover, .site-nav a[aria-current] { color: var(--text); }
.site-nav a[aria-current] { border-color: var(--accent); }
.telegram-profile { display: flex; margin-left: auto; align-items: center; gap: 10px; font-size: .82rem; }
.telegram-profile img { object-fit: cover; border-radius: 50%; }

main { padding: 38px 0 24px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 15px; margin-bottom: 23px; }
.page-heading p { margin-top: 6px; color: var(--muted); font-size: .9rem; }
.separator { margin: 0 5px; color: #7790ab; }
.mode-label { color: #c5d9f3; border: 1px solid #405675; background: #1b2d44; border-radius: 6px; padding: 6px 10px; font-size: .8rem; white-space: nowrap; align-self: start; }
.panel { min-width: 0; background: var(--surface); border: 1px solid var(--stroke); border-radius: 12px; }
.panel-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.panel-heading > span { color: var(--muted); font-size: .86rem; }
.panel-heading a { font-size: .86rem; }

.overview-grid { display: grid; grid-template-columns: 1.58fr 1fr; gap: 16px; }
.overview, .control { padding: 20px 22px; }
.overview {
  background: linear-gradient(112deg, #20344b, var(--surface) 74%);
  display: flex;
  flex-direction: column;
}
.portfolio-result { display: grid; align-content: center; gap: 6px; flex: 1; padding-block: 20px 23px; }
.portfolio-result span { color: var(--muted); font-size: .9rem; }
.portfolio-result strong { font-size: clamp(2rem, 4vw, 3.35rem); letter-spacing: -.055em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; border-top: 1px solid var(--stroke); padding-top: 14px; }
.metrics dd { margin-top: 5px; font-size: 1.2rem; font-variant-numeric: tabular-nums; font-weight: 650; overflow-wrap: anywhere; }
.connection { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.connection::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
[data-tone="good"] { color: var(--positive) !important; }
[data-tone="bad"] { color: var(--negative) !important; }
[data-tone="warn"] { color: var(--warning) !important; }
.control h2 { margin-top: 13px; font-size: 1.45rem; letter-spacing: -.025em; }
#message { margin: 4px 0 12px; color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.schedule, .diagnostic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.schedule { background: var(--inset); padding: 10px 12px; border-radius: 7px; margin-bottom: 12px; }
.schedule dd, .diagnostic-grid dd { margin-top: 4px; font-variant-numeric: tabular-nums; }
.feedback { color: var(--muted); font-size: .8rem; margin-top: 6px; }
.feedback:empty { display: none; }

.desk { margin-top: 16px; }
.tabs {
  display: flex;
  align-items: stretch;
  overflow-x: auto;
  padding: 0 12px;
  border-bottom: 1px solid var(--stroke);
  border-radius: 12px 12px 0 0;
  background: var(--header);
  scrollbar-width: thin;
}
.tabs button {
  padding: 12px 14px 11px;
  border-radius: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  min-height: 45px;
  color: var(--muted);
  background: transparent;
  white-space: nowrap;
}
.tabs button:focus-visible { outline-offset: -4px; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--accent); background: #203047; }
.desk-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 17px 20px; }
.desk-heading p { font-size: .84rem; color: var(--muted); margin-top: 3px; }
.desk-heading input { max-width: 100%; background: var(--inset); color: var(--text); border: 1px solid #40536a; border-radius: 7px; padding: 8px 10px; }
.desk-heading input::placeholder { color: var(--muted); }
.table-scroll { overflow: auto; scrollbar-width: thin; }
.coin-list { max-height: 450px; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 15px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--stroke); }
th { background: var(--inset); color: var(--muted); font-weight: 550; }
.coin-list th { position: sticky; top: 0; }
td:first-child, th:first-child { text-align: left; padding-left: 20px; }
td:last-child, th:last-child { padding-right: 20px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #203044; }
#panel-coins th:last-child, #panel-coins td:last-child, #panel-events th:last-child, #panel-events td:last-child { text-align: left; }
.empty { margin: 0 20px 18px; border: 1px dashed #374b61; border-radius: 7px; padding: 17px 14px; color: var(--muted); background: var(--inset); font-size: .88rem; }
.desk-details { margin: 0 20px; padding: 12px 0; }
.desk-details p { padding-top: 8px; }
.diagnostics { padding: 13px 16px; margin-top: 16px; color: var(--muted); font-size: .86rem; }
summary { cursor: pointer; color: #ced8e6; font-weight: 550; }
summary span { color: var(--warning); margin-left: 6px; }
.diagnostic-grid { margin-block: 14px; }
.diagnostics p + p { margin-top: 8px; }
.warning { border-left: 2px solid var(--warning); color: var(--warning); padding: 5px 10px; overflow-wrap: anywhere; }
footer { font-size: .8rem; color: var(--muted); margin-top: 20px; }

.notice-list { max-height: 380px; overflow: auto; padding-inline: 20px; }
.notice-item, .toast { padding: 12px 14px; background: var(--inset); border: 1px solid var(--stroke); border-left: 3px solid var(--accent); border-radius: 7px; margin-bottom: 10px; }
.notice-item.error, .toast.error { border-left-color: var(--negative); }
.notice-item.trade { border-left-color: var(--positive); }
.notice-item.signal { border-left-color: var(--warning); }
.notice-item p, .toast p { margin: 5px 0; color: var(--muted); }
#toast-tray { position: fixed; z-index: 10; right: 16px; bottom: 8px; width: min(400px, calc(100% - 32px)); }
.toast { box-shadow: 0 8px 24px #0a1019aa; }
.toast button { min-height: 28px; padding: 2px 8px; font-size: .77rem; }
dialog.panel { background: var(--surface); color: var(--text); padding: 23px; width: min(420px, calc(100% - 32px)); }
dialog::backdrop { background: #080e17bd; }
dialog p { margin: 10px 0 17px; color: var(--muted); }
dialog .buttons { justify-content: flex-end; }
.login-card { width: min(100% - 36px, 450px); margin: 10vh auto 0; }
.login-card .panel { padding: 22px; }
.login-card p { margin: 12px 0; }
.telegram-button { display: inline-block; padding: 9px 13px; background: var(--accent); color: #142236; border-radius: 7px; text-decoration: none; font-weight: 650; }

.analytics-status { font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
.analytics-summary, .chart-panel { padding: 17px 19px; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 13px; }
.summary-grid h3 { font-size: .82rem; font-weight: 650; margin-bottom: 7px; }
.summary-grid .metrics { padding-top: 10px; }
.summary-grid small { display: block; margin-top: 4px; line-height: 1.2; font-size: .74rem; }
.chart-panel { margin-top: 16px; }
.chart-value { margin-top: 5px; font-size: 1.82rem; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.035em; }
.chart-panel .panel-heading { align-items: start; }
.period-control { display: flex; flex-wrap: wrap; gap: 3px; padding: 3px; margin: 0; border: 1px solid var(--stroke); border-radius: 8px; background: var(--inset); min-inline-size: 0; }
.period-control legend { position: absolute; clip-path: inset(50%); }
.period-control label { position: relative; cursor: pointer; }
.period-control input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: inherit; }
.period-control label span { display: block; border-radius: 5px; padding: 6px 8px; font-size: .8rem; color: var(--muted); }
.period-control input:checked + span { background: #2a4261; color: #f4f8ff; }
.period-control input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
.chart-frame {
  position: relative;
  min-width: 0;
  height: 265px;
  margin-top: 13px;
  border: 1px solid var(--stroke);
  border-radius: 8px;
  overflow: hidden;
  background: var(--inset);
}
.chart-frame:focus-within { border-color: var(--accent); }
.chart-frame.chart-small { height: 206px; }
.chart-frame canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.chart-empty {
  height: 100%;
  display: grid;
  place-content: center;
  gap: 5px;
  text-align: center;
  padding: 12px;
  background-image: linear-gradient(#26374a77 1px, transparent 1px), linear-gradient(90deg, #26374a77 1px, transparent 1px);
  background-size: 100% 44px, 18% 100%;
}
.chart-empty strong, .chart-empty span { background: var(--inset); padding: 2px 7px; border-radius: 4px; justify-self: center; }
.chart-empty span { color: var(--muted); font-size: .84rem; }
.chart-tooltip {
  position: absolute;
  top: 7px;
  pointer-events: none;
  z-index: 1;
  max-width: calc(100% - 16px);
  padding: 7px 9px;
  border: 1px solid #4b627a;
  border-radius: 6px;
  background: #192b40;
  color: var(--text);
  font-size: .78rem;
  white-space: pre-line;
  font-variant-numeric: tabular-nums;
}
.risk-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: .8rem; color: var(--muted); margin-top: 10px; }
.legend-key { display: inline-flex; align-items: center; gap: 6px; }
.legend-key::before { content: ""; width: 15px; border-top: 2px solid var(--line); }
.equity-key { --line: var(--equity-line); }
.equity-key.total-key::before { border-top-style: dashed; }
.closed-key { --line: var(--closed-line); }
.closed-key::before { border-top-style: dashed; }
.long-key { --line: var(--long-line); }
.short-key { --line: var(--short-line); }
.yearly { margin-top: 16px; }
.yearly .panel-heading { padding: 16px 19px; }

@media (max-width: 900px) {
  .header-inner, main { width: calc(100% - 40px); }
  .overview-grid { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .header-inner, main { width: calc(100% - 28px); }
  .header-inner { min-height: 0; flex-wrap: wrap; gap: 0 13px; }
  .brand { min-height: 48px; }
  .site-nav { gap: 18px; }
  .site-nav a { min-height: 39px; }
  .telegram-profile { padding: 5px 0; }
  main { padding-top: 22px; }
  .page-heading { flex-wrap: wrap; margin-bottom: 16px; }
  .overview-grid, .risk-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .risk-grid { margin-top: 12px; }
  .risk-grid .chart-panel { margin-top: 0; }
  .overview, .control, .analytics-summary, .chart-panel { padding: 14px; }
  .summary-grid { gap: 12px; }
  .summary-grid .metrics { gap: 8px; }
  .summary-grid dt { font-size: .76rem; }
  .chart-panel .panel-heading { flex-wrap: wrap; }
  .chart-frame { height: 228px; }
  .tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 0; }
  .tabs button { padding-inline: 5px; }
  .desk-heading { padding: 13px; }
  .empty { margin-inline: 13px; }
  .yearly th, .yearly td { padding: 9px 8px; white-space: normal; }
}
@media (max-width: 390px) {
  .brand { width: 100%; }
  .summary-grid { grid-template-columns: minmax(0, 1fr); gap: 7px; }
  .summary-grid .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-heading a { font-size: .78rem; }
}
