:root {
  --bg: #131722;
  --panel: #1e222d;
  --border: #2a2e39;
  --text: #d1d4dc;
  --muted: #787b86;
  --accent: #2962ff;
  --up: #089981;
  --down: #f23645;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
}

body { display: flex; flex-direction: column; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.toolbar select, .settings input, .settings select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
}

.tfs { display: flex; gap: 2px; }
.tfs button, .icon-btn {
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 4px;
  padding: 5px 8px;
  cursor: pointer;
  font: inherit;
}
.tfs button:hover, .icon-btn:hover { background: var(--panel); }
.tfs button.active { color: var(--accent); background: rgba(41, 98, 255, .12); }
.tfs button .dot { display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--up); margin-left: 4px; vertical-align: middle; }
.icon-btn { font-size: 16px; }

.spacer { flex: 1; }
.status { color: var(--muted); font-size: 12px; }
.status.live::before { content: "● "; color: var(--up); }
.status.demo, .status.error { color: #ff9800; }

.bars-input { display: flex; align-items: center; gap: 4px; color: var(--muted); margin-left: 6px; }
.bars-input input {
  width: 78px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font: inherit;
}

.workspace { flex: 1; min-height: 0; display: flex; }
.chart-wrap { position: relative; flex: 1; min-width: 0; }

/* ---------- dashboard panel ---------- */
.dash {
  width: 360px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dash.collapsed { display: none; }
.dash-tabs { display: flex; border-bottom: 1px solid var(--border); }
.dash-tabs button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 9px 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.dash-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.dash-body { overflow-y: auto; padding: 10px 12px 16px; flex: 1; }
.dash-body h4 { margin: 16px 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; }
.note { color: var(--muted); font-size: 11px; margin: 6px 0; }

.seg { display: flex; background: var(--panel); border-radius: 6px; padding: 2px; }
.seg button {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 4px;
  padding: 5px 0;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}
.seg button.active { background: var(--accent); color: #fff; }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }
.month-nav button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 28px;
  height: 26px;
  cursor: pointer;
}

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tile { background: var(--panel); border-radius: 6px; padding: 7px 9px; }
.tile .lbl { color: var(--muted); font-size: 11px; }
.tile .val { font-size: 17px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .sub { color: var(--muted); font-size: 10px; margin-top: 1px; }
.pos { color: #26a69a; }
.neg { color: #f23645; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 10px; }
.cal .dow { text-align: center; color: var(--muted); font-size: 10px; padding-bottom: 2px; }
.cal .day {
  background: var(--panel);
  border-radius: 4px;
  min-height: 46px;
  padding: 3px 4px;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  border: 1px solid transparent;
}
.cal .day.empty { background: transparent; }
.cal .day .d { color: var(--muted); }
.cal .day .p { font-weight: 600; margin-top: auto; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.cal .day .n { color: var(--muted); font-size: 9px; }
.cal .day.win { background: rgba(38, 166, 154, .16); }
.cal .day.loss { background: rgba(242, 54, 69, .16); }
.cal .day.today { border-color: var(--accent); }

.months { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.months td { padding: 4px 2px; border-bottom: 1px solid var(--border); }
.months td:not(:first-child) { text-align: right; }
.months tr { cursor: pointer; }
.months tr:hover td { background: var(--panel); }

.news-day { display: flex; justify-content: space-between; margin: 12px 0 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.news-day.today { color: var(--text); }
.news-day .cnt { font-weight: 400; font-size: 11px; }
.news-item .fp b { color: var(--text); font-weight: 600; }
.note { white-space: pre-line; }
.news-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 2px 8px;
  padding: 6px 8px;
  border-left: 3px solid #f23645;
  background: var(--panel);
  border-radius: 0 4px 4px 0;
  margin-bottom: 4px;
  font-size: 12px;
}
.news-item .t { font-weight: 600; font-variant-numeric: tabular-nums; }
.news-item .fp { grid-column: 2; color: var(--muted); font-size: 11px; }
.news-item.past { opacity: .45; }
.news-item.next { outline: 1px solid #f23645; }
.news-item .soon { color: #ff9800; font-size: 11px; grid-column: 2; }

/* ---------- user box, blocked screen, my account ---------- */
.user-box { display: flex; align-items: center; gap: 10px; padding-left: 8px; border-left: 1px solid var(--border); font-size: 12px; }
.user-box .who { color: var(--text); font-weight: 600; }
.user-box a, .link-btn { color: var(--muted); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-decoration: none; }
.user-box a:hover, .link-btn:hover { color: var(--text); }

.access-blocked { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; background: rgba(19, 23, 34, .92); padding: 16px; }
.blocked-card { max-width: 420px; text-align: center; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 24px; }
.blocked-card h3 { margin: 0 0 8px; color: var(--down); }
.blocked-card p { margin: 6px 0; }
.muted { color: var(--muted); }

.seg-sm { margin-top: 6px; }
.seg-sm button { padding: 3px 0; font-size: 11px; }

.acc-status { border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; }
.acc-status .lbl { font-size: 11px; color: var(--muted); }
.acc-status .val { font-size: 18px; font-weight: 700; }
.acc-status.ok { background: rgba(38, 166, 154, .15); }
.acc-status.ok .val { color: #26a69a; }
.acc-status.warn { background: rgba(255, 152, 0, .15); }
.acc-status.warn .val { color: #ff9800; }
.acc-status.bad { background: rgba(242, 54, 69, .15); }
.acc-status.bad .val { color: var(--down); }
.acc-block { background: var(--panel); border-radius: 6px; padding: 4px 10px; }
.acc-block .row { display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; font-size: 12px; border-bottom: 1px solid var(--border); }
.acc-block .row:last-child { border-bottom: 0; }
.acc-block .row span { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: 11px; }
.progress { height: 8px; background: var(--panel); border-radius: 4px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); }
.row-note { font-size: 12px; color: var(--muted); margin-top: 6px; }
.row-note b { color: var(--text); }
.lbl-sm { font-size: 11px; color: var(--muted); margin: 10px 0 4px; }
.tf-pick { display: flex; gap: 14px; }
.tf-pick label { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.tf-pick label.disabled { opacity: .4; cursor: not-allowed; }

.guide { margin: 0; padding-left: 18px; font-size: 12px; color: var(--muted); }
.guide li { margin-bottom: 6px; }
.guide a { color: var(--accent); }
.guide b { color: var(--text); }
.events { display: flex; flex-direction: column; gap: 3px; font-size: 11px; }
.ev { display: grid; grid-template-columns: 82px 52px 1fr; gap: 6px; padding: 4px 6px; background: var(--panel); border-radius: 4px; border-left: 3px solid var(--muted); }
.ev span:first-child { color: var(--muted); }
.ev.opened { border-left-color: #26a69a; }
.ev.skipped { border-left-color: #ff9800; }
.ev.error, .ev.halt { border-left-color: var(--down); }

@media (max-width: 900px) {
  .workspace { flex-direction: column; }
  .chart-wrap { min-height: 60vh; }
  .dash { width: auto; border-left: 0; border-top: 1px solid var(--border); }
  body { height: auto; min-height: 100%; }
}
#chart { position: absolute; inset: 0; }

.legend {
  position: absolute;
  top: 8px;
  left: 10px;
  z-index: 3;
  pointer-events: none;
  font-size: 12px;
}
.legend .sym { font-size: 14px; font-weight: 600; margin-right: 8px; }
.legend .k { color: var(--muted); margin-left: 6px; }

.stats {
  position: absolute;
  top: 8px;
  right: 72px;
  z-index: 3;
  border-collapse: collapse;
  background: rgba(0, 0, 0, .8);
  font-size: 12px;
  pointer-events: none;
}
.stats th, .stats td { border: 1px solid #555; padding: 3px 8px; }
.stats th { background: #787b86; color: #fff; font-weight: 600; }
.stats td:last-child { text-align: center; }

.tooltip {
  position: absolute;
  z-index: 4;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.settings {
  position: fixed;
  top: 44px;
  right: 8px;
  z-index: 10;
  width: 300px;
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 60px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 14px 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .5);
}
.settings-note { font-size: 11px; color: var(--muted); margin: 10px 0 0; }
#settingsNote { color: #26a69a; min-height: 14px; margin-top: 4px; }
.settings h3 { font-size: 12px; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }
.settings label { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; }
.settings label:has(input[type=checkbox]) { justify-content: flex-start; }
.settings input[type=number] { width: 80px; }
.settings .reset {
  margin-top: 14px;
  width: 100%;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px;
  cursor: pointer;
}

.attribution {
  font-size: 10px;
  color: var(--muted);
  padding: 2px 10px;
  border-top: 1px solid var(--border);
}
.attribution a { color: var(--muted); }
