:root {
  color-scheme: dark;
  --bg: #070504;
  --surface: #120d0a;
  --surface-2: #1b1410;
  --border: #2b211b;
  --text: #f6efe9;
  --muted: #a89a8f;
  --accent: #ff7a1a;
  --ok: #4ade80;
  --warn: #fbbf24;
  --danger: #f87171;
  font-family: Manrope, system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 12px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 24px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--border);
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 24px clamp(16px, 4vw, 40px) 48px;
  max-width: 1280px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  min-width: 0;
}

.card.wide {
  grid-column: 1 / -1;
}

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

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--muted);
}

.badge[data-tone="ok"] {
  background: rgb(74 222 128 / 0.14);
  color: var(--ok);
}

.badge[data-tone="warn"] {
  background: rgb(251 191 36 / 0.14);
  color: var(--warn);
}

.badge[data-tone="danger"] {
  background: rgb(248 113 113 / 0.14);
  color: var(--danger);
}

.button {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--accent);
  color: #1a0d03;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.button.danger {
  background: var(--danger);
  color: #1f0606;
}

.confirm-row {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgb(248 113 113 / 0.35);
  border-radius: 10px;
  background: rgb(248 113 113 / 0.07);
}

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

.button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

form {
  margin-top: 14px;
}

.consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 14px 0;
  font-weight: 500;
}

.consent input {
  margin-top: 4px;
  accent-color: var(--accent);
}

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgb(251 191 36 / 0.3);
  background: rgb(251 191 36 / 0.07);
  margin-bottom: 4px;
}

.status-detail {
  font-weight: 600;
  margin-bottom: 12px;
}

.qr-box {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-wrap: wrap;
}

.qr-box img,
.token-result img {
  background: #fff;
  border-radius: 12px;
  display: block;
}

.qr-box ol {
  margin: 0;
  padding-left: 18px;
}

.qr-box li {
  margin-bottom: 4px;
}

.token-result {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.token-result p {
  flex: 1 1 160px;
}

.connected-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.error {
  color: var(--danger);
  margin-top: 10px;
  font-weight: 600;
}

.success {
  color: var(--ok);
  margin-top: 10px;
  font-weight: 600;
}

input:disabled {
  opacity: 0.5;
}

input::placeholder {
  color: var(--muted);
}

.hint {
  font-size: 13px;
  margin: -4px 0 12px;
}

.connected-row .muted {
  margin-top: 2px;
}

.choices {
  border: 0;
  margin: 0 0 12px;
  padding: 0;
}

.choices legend {
  font-weight: 600;
  margin-bottom: 6px;
  padding: 0;
}

.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin-bottom: 4px;
}

.choice input {
  accent-color: var(--accent);
}

h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 20px 0 8px;
}

.webhook-info {
  margin: 0;
}

.webhook-info dt {
  font-weight: 600;
  margin-top: 10px;
}

.webhook-info dd {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 4px 0 0;
}

.webhook-info code {
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 13px;
  word-break: break-all;
}

.button.small {
  padding: 6px 12px;
  font-size: 13px;
}

.checks,
.events {
  list-style: none;
  margin: 0;
  padding: 0;
}

.checks li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.checks li:first-child {
  border-top: 0;
}

.check-name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot[data-tone="ok"] {
  background: var(--ok);
}

.dot[data-tone="danger"] {
  background: var(--danger);
}

.check-detail {
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin: 0;
}

.stat {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px 14px;
}

.stat dt {
  color: var(--muted);
  font-size: 12px;
}

.stat dd {
  margin: 2px 0 0;
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.events li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}

.events li:first-child {
  border-top: 0;
}

.empty {
  color: var(--muted);
  padding: 10px 0;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  text-align: left;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  border-top: 0;
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .check-detail {
    white-space: normal;
    max-width: 45%;
  }
}
