:root {
  color-scheme: dark;
  --bg: #0c141d;
  --panel: #111e2a;
  --raised: #182a39;
  --line: #2c4051;
  --text: #e0e8ef;
  --muted: #a2b5c5;
  --accent: #8cc7f4;
  --amber: #f0bf72;
  --red: #ef9b9b;
  --green: #83cfb5;
  --blue: #72b9ed;
  --radius: 4px;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 13px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  background: var(--raised);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  min-height: 34px;
}
button:hover {
  background: #233e53;
  border-color: #7796ad;
}
button:disabled {
  opacity: 0.55;
  cursor: wait;
}
button.primary {
  background: #9bc7e8;
  border-color: #9bc7e8;
  color: #102332;
  font-weight: 650;
}
button.primary:hover {
  background: #c1def3;
}
input,
select,
textarea {
  background: #0c1823;
  border: 1px solid #51697d;
  color: var(--text);
  padding: 9px;
  border-radius: var(--radius);
  width: 100%;
  min-height: 36px;
}
textarea {
  resize: vertical;
  min-height: 60px;
}
::placeholder {
  color: var(--muted);
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
::selection {
  color: #102332;
  background: #aed4ef;
}
* {
  scrollbar-color: #51697d var(--bg);
}
header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 17px 24px;
  border-bottom: 1px solid var(--line);
  background: #122435;
}
.brand {
  color: var(--text);
  font-size: 17px;
  letter-spacing: 0.03em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.brand strong {
  color: #9bc7e8;
  font-weight: 650;
}
.brand-mark {
  display: inline-block;
  width: 15px;
  height: 18px;
  border-top: 3px solid #9bc7e8;
  border-bottom: 3px solid #9bc7e8;
  transform: skewY(-18deg);
  margin-right: 7px;
}
.local {
  color: var(--muted);
  font-size: 12px;
}
.header-actions {
  margin-left: auto;
  display: flex;
  gap: 9px;
  align-items: center;
}
#clock {
  color: var(--muted);
  margin-right: 10px;
  font-variant-numeric: tabular-nums;
}
nav {
  padding: 0 24px;
  display: flex;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  background: #101d28;
}
nav button {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 13px 15px;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav button.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  background: #192c3d;
}
#event-count {
  font-size: 11px;
  color: var(--amber);
  margin-left: 3px;
}
main {
  max-width: 1780px;
  margin: auto;
  padding: 24px;
  min-height: calc(100vh - 170px);
}
h1 {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
  margin: 0 0 7px;
}
h2 {
  font-size: 15px;
  margin: 0;
  font-weight: 600;
}
h3 {
  font-size: 14px;
  margin: 0 0 8px;
}
p {
  line-height: 1.5;
  margin: 8px 0;
}
.subtitle,
.muted {
  color: var(--muted);
}
.subtitle {
  margin: 0;
  max-width: 100ch;
}
.page-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}
.stamp {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
  background: var(--panel);
  margin: 20px 0;
}
.strip > div {
  padding: 13px 17px;
  border-right: 1px solid var(--line);
}
.strip > div:last-child {
  border: 0;
}
.strip strong {
  font-size: 21px;
  font-weight: 600;
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}
.strip span {
  color: var(--muted);
  font-size: 12px;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: start;
}
.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-body {
  padding: 15px 16px;
}
.panel-head .muted {
  font-size: 12px;
}
.pill {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 3px 7px;
  border-radius: 3px;
  font-size: 11px;
  white-space: nowrap;
}
.amber {
  color: var(--amber);
}
.red {
  color: var(--red);
}
.green {
  color: var(--green);
}
.blue {
  color: var(--blue);
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 15px 0;
}
.toolbar input {
  width: 260px;
}
.toolbar select {
  width: auto;
}
.toolbar label {
  display: flex;
  gap: 8px;
  align-items: center;
}
.toolbar input[type="checkbox"] {
  width: 16px;
  min-height: 16px;
}
.table-wrap {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 10px 14px;
  background: #122332;
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-top: 1px solid #243748;
  vertical-align: middle;
}
td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}
.series-row {
  cursor: pointer;
}
.series-row:hover,
.series-row.selected {
  background: #1b3041;
}
.series-name {
  font-weight: 550;
}
.series-code {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--muted);
}
.state-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.state-line:first-child {
  padding-top: 0;
}
.state-line:last-child {
  border: 0;
  padding-bottom: 0;
}
.state-line small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}
.chart {
  width: 100%;
  height: 230px;
  display: block;
}
.chart text {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 11px;
  fill: var(--muted);
}
.chart path {
  stroke: var(--accent);
  stroke-width: 2;
  fill: none;
  vector-effect: non-scaling-stroke;
}
.chart line {
  stroke: var(--line);
  stroke-width: 1;
}
.chart circle {
  fill: var(--accent);
}
.chart-meta {
  display: flex;
  justify-content: space-between;
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
}
.detail-value {
  font-size: 27px;
  font-variant-numeric: tabular-nums;
  margin: 12px 0;
}
.detail-value small {
  font-size: 13px;
  color: var(--muted);
}
.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
  margin: 15px 0;
}
.facts dt {
  font-size: 11px;
  color: var(--muted);
}
.facts dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}
.explanation {
  background: #172b3b;
  padding: 12px 14px;
  color: #c2d5e4;
  line-height: 1.55;
}
.event {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}
.event:last-child {
  border: 0;
}
.event-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.event-title h3 {
  margin: 0;
}
.event p {
  max-width: 100ch;
}
.event-meta {
  color: var(--muted);
  font-size: 11px;
  margin: 8px 0;
}
.event-actions {
  display: flex;
  gap: 7px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.event-actions button {
  font-size: 12px;
  padding: 5px 9px;
}
.empty {
  padding: 26px 20px;
  color: var(--muted);
  line-height: 1.6;
}
.empty strong {
  display: block;
  color: var(--text);
  font-weight: 550;
  margin-bottom: 5px;
}
.link-list a {
  display: block;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.link-list a:hover {
  background: var(--raised);
}
.link-list a:last-child {
  border: 0;
}
.hypothesis-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}
.hypothesis-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.full {
  grid-column: 1/-1;
}
.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}
.watch-fields {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 10px;
}
.hypothesis {
  padding: 17px;
  border-bottom: 1px solid var(--line);
}
.hypothesis:last-child {
  border: 0;
}
.hypothesis h3 {
  font-size: 16px;
}
.hypothesis .conditions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 14px;
}
.conditions strong {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 5px;
}
.coverage {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}
.coverage b {
  color: var(--text);
  font-weight: 550;
}
footer {
  border-top: 1px solid var(--line);
  padding: 13px 24px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  gap: 20px;
}
#notice {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #264053;
  border-bottom: 1px solid #7292ab;
  padding: 12px 24px;
  color: var(--text);
}
#notice.error {
  background: #472c2f;
  border-color: #af7478;
}
.skip {
  position: absolute;
  left: 16px;
  top: -50px;
  z-index: 9;
  background: var(--panel);
  padding: 10px;
}
.skip:focus {
  top: 8px;
}
.loading {
  color: var(--muted);
  padding: 25px;
}
.small {
  font-size: 12px;
}
.health-note {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid #78633e;
  background: #2b291f;
  color: var(--amber);
}
.chart-controls {
  display: flex;
  gap: 6px;
}
.chart-controls button {
  font-size: 11px;
  padding: 4px 8px;
  min-height: 27px;
}
.chart-controls button.active {
  color: var(--accent);
  border-color: var(--accent);
}
details summary {
  cursor: pointer;
  color: var(--accent);
  padding: 10px 0;
}
details pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.55;
  max-height: 450px;
  overflow: auto;
}
.event.read {
  opacity: 0.75;
}
.overview-change {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
}
.overview-change:last-child {
  border: 0;
}
.stack {
  display: grid;
  gap: 3px;
}
.sticky-detail {
  position: sticky;
  top: 18px;
}
.error-box {
  border: 1px solid #946769;
  background: #342429;
  padding: 20px;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (min-width: 1500px) {
  .workspace {
    grid-template-columns: minmax(0, 1.9fr) minmax(380px, 1fr);
  }
  td {
    padding-top: 13px;
    padding-bottom: 13px;
  }
}
@media (max-width: 1050px) {
  header {
    gap: 12px;
  }
  .local,
  #clock {
    display: none;
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  .sticky-detail {
    position: static;
  }
  .strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .strip > div:nth-child(2) {
    border-right: 0;
  }
  .strip > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
  nav {
    padding: 0 12px;
  }
  main {
    padding: 18px;
  }
  .stamp {
    max-width: 210px;
  }
}
@media (max-width: 600px) {
  header {
    padding: 12px;
    flex-wrap: wrap;
  }
  .brand {
    font-size: 15px;
  }
  .header-actions {
    width: 100%;
    margin: 0;
  }
  .header-actions button {
    flex: 1;
    padding: 8px 5px;
    font-size: 12px;
  }
  main {
    padding: 16px 12px;
  }
  .page-top {
    display: block;
  }
  .stamp {
    text-align: left;
    max-width: none;
    margin-top: 10px;
  }
  h1 {
    font-size: 22px;
  }
  .strip {
    margin: 15px 0;
  }
  .strip > div {
    padding: 11px;
  }
  .strip strong {
    font-size: 18px;
  }
  .strip span {
    font-size: 11px;
  }
  .hypothesis-form {
    grid-template-columns: 1fr;
  }
  .full {
    grid-column: auto;
  }
  .watch-fields {
    grid-template-columns: 1fr;
  }
  .hypothesis .conditions {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .toolbar input {
    width: 100%;
  }
  .panel-head {
    padding: 12px;
  }
  .panel-body {
    padding: 12px;
  }
  td,
  th {
    padding: 10px;
  }
  .desktop-col {
    display: none;
  }
  .event-title {
    display: block;
  }
  .event-title .pill {
    margin-top: 8px;
  }
  footer {
    padding: 12px;
    display: block;
  }
  footer span {
    display: block;
    margin: 4px 0;
  }
  .chart {
    height: 205px;
  }
  .facts {
    gap: 10px;
  }
  .chart-meta {
    flex-wrap: wrap;
    gap: 5px;
  }
  .toolbar {
    gap: 8px;
  }
  .coverage {
    gap: 9px;
  }
}
@media (prefers-reduced-motion: no-preference) {
  #notice {
    animation: notice-in 0.18s ease-out;
  }
  @keyframes notice-in {
    from {
      clip-path: inset(0 0 100% 0);
    }
    to {
      clip-path: inset(0);
    }
  }
}

.mobile-status {
  display: none;
}
@media (max-width: 600px) {
  .mobile-status {
    display: block !important;
  }
}


/* BTC live panel: retain the incumbent terminal palette and density. */
.btc-live-panel { margin-top: 16px; min-width: 0; }
.btc-live-panel .panel-head { gap: 12px; flex-wrap: wrap; }
.btc-live-panel .panel-body > p { margin: 8px 0; }
.btc-live-panel .table-wrap { max-width: 100%; overflow-x: auto; }
.btc-live-panel table { width: 100%; font-variant-numeric: tabular-nums; }
.btc-live-panel th, .btc-live-panel td { padding: 8px 10px; text-align: left; }
.btc-live-panel tbody th { font-weight: 600; }
.btc-live-panel small { display: block; color: var(--muted); }
.btc-live-panel details { margin-top: 10px; }
.btc-live-panel summary { cursor: pointer; width: fit-content; }
.btc-live-panel summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.btc-live-history { max-height: 280px; margin-top: 8px; }
.btc-live-limit { color: var(--muted); }
@media (max-width: 600px) {
  .btc-live-panel .panel-head { align-items: flex-start; }
  .btc-live-panel .btc-live-table { min-width: 0; }
  .btc-live-table thead { display: none; }
  .btc-live-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .btc-live-table tbody th { grid-column: 1 / -1; padding: 0 0 4px; background: none; }
  .btc-live-table tbody td { padding: 2px 0; border: 0; white-space: normal; }
  .btc-live-table tbody td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
  .btc-live-history thead { display: none; }
  .btc-live-history tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .btc-live-history tbody td { padding: 2px 0; border: 0; white-space: normal; }
  .btc-live-history tbody td:first-child { grid-column: 1 / -1; }
  .btc-live-history tbody td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; margin-bottom: 2px; }
  .btc-live-panel .panel-body { padding: 10px; }
}
