:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --ink: #172033;
  --muted: #657084;
  --line: #d9e0ea;
  --panel: #ffffff;
  --green: #1f8a5b;
  --blue: #285eaa;
  --amber: #a15d10;
  --red: #b42318;
  --shadow: 0 14px 35px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  padding: 0 16px;
  color: #ffffff;
  background: var(--blue);
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  opacity: 0.58;
  cursor: wait;
}

button.secondary {
  color: var(--ink);
  background: #e8edf5;
}

button.ghost {
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
}

button.top-logout {
  min-height: 38px;
  padding: 0 12px;
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--ink);
}

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.top-status {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 10px;
  flex-wrap: wrap;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
}

h2 {
  font-size: 20px;
  line-height: 1.15;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 420px);
  gap: 20px;
  align-items: end;
  padding: 22px;
}

.auth-panel p {
  margin-top: 8px;
  color: var(--muted);
}

.token-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.form-error {
  grid-column: 1 / -1;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
}

.app-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.status-panel,
.ladder-panel,
.events-panel {
  padding: 18px;
}

.events-panel {
  grid-column: 1 / -1;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.section-head.compact {
  margin-bottom: 14px;
}

#btc-price {
  font-size: 42px;
  line-height: 1;
}

.pill,
.tier {
  min-width: 78px;
  border-radius: 999px;
  padding: 8px 12px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.pill.ok,
.tier.watch {
  color: #0f5132;
  background: #dff4e8;
}

.pill.warn,
.tier.active {
  color: #7a2e0e;
  background: #ffe6c6;
}

.pill.error {
  color: #842029;
  background: #f8d7da;
}

.pill.muted {
  color: var(--muted);
  background: #e8edf5;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.metric-grid div {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  background: #fafbfe;
}

.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-grid strong {
  display: block;
  margin-top: 7px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.ladder-list,
.events-list {
  display: grid;
  gap: 10px;
}

.tier-row,
.event-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #fafbfe;
}

.tier-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.tier-key {
  width: 62px;
  border-radius: 7px;
  padding: 8px 7px;
  text-align: center;
  color: #ffffff;
  background: var(--ink);
  font-weight: 800;
}

.tier-row.active .tier-key {
  background: var(--amber);
}

.tier-main strong,
.event-row strong {
  display: block;
}

.tier-main span,
.event-row span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.tier-price {
  font-weight: 800;
  white-space: nowrap;
}

.event-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
}

.event-time {
  color: var(--muted);
  font-size: 13px;
}

.error-line {
  margin-top: 14px;
  color: var(--red);
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 22px, 1040px);
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: end;
  }

  .top-status {
    align-items: end;
  }

  h1 {
    font-size: 29px;
  }

  .auth-panel,
  .app-grid {
    grid-template-columns: 1fr;
  }

  .token-form {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .event-row,
  .tier-row {
    grid-template-columns: 1fr;
  }

  .tier-key {
    width: auto;
  }

  #btc-price {
    font-size: 35px;
  }
}
