:root {
  --bg: #f3f5f4;
  --surface: #ffffff;
  --text: #16211c;
  --muted: #5d6b64;
  --line: #dfe5e2;
  --brand: #0a7c5c;
  --brand-dark: #07634a;
  --danger: #b3261e;
  --warn-bg: #fdf3dc;
  --warn-text: #7a5300;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

h1 { margin: 0; font-size: 1.4rem; }
h2 { margin: 0 0 16px; font-size: 1.1rem; }

.page { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 16px;
}
body.center .card { margin-bottom: 0; }

.login { width: 100%; max-width: 360px; }
.login h1 { margin-bottom: 16px; }
.login button { width: 100%; margin-top: 12px; }

label { display: block; font-size: 0.875rem; font-weight: 600; }

input, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}

button {
  padding: 10px 16px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover { background: var(--brand-dark); }
button.ghost { background: transparent; color: var(--brand); padding: 6px 12px; font-size: 0.875rem; }
button.ghost:hover { background: var(--bg); }
button.ghost.danger { color: var(--danger); border-color: var(--danger); }

.grid { display: grid; grid-template-columns: 2fr 2fr 1fr auto; gap: 12px; align-items: end; }
.created { display: flex; gap: 8px; margin-top: 16px; }
.created input { margin-top: 0; }

.muted { color: var(--muted); }
.error { color: var(--danger); margin: 12px 0 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
th { text-align: left; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.actions { text-align: right; }
.actions button + button { margin-left: 6px; }

.badge { padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge.opened { background: var(--warn-bg); color: var(--warn-text); }
.badge.connected { background: #dcf3ea; color: var(--brand-dark); }

.connect { width: 100%; max-width: 440px; text-align: center; }
.connect #label { margin: 4px 0 0; }
.qr-frame { margin: 16px auto 8px; width: min(100%, 320px); aspect-ratio: 1; background: #fff; }
.qr-frame img { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.live { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0; color: var(--muted); font-size: 0.875rem; }
.dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: pulse 2s infinite; }
.steps { margin: 16px 0 0; padding-left: 20px; text-align: left; font-size: 0.925rem; }
.steps li + li { margin-top: 4px; }
.hint { margin: 16px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--warn-bg); color: var(--warn-text); font-size: 0.875rem; text-align: left; }
.icon { margin-top: 16px; font-size: 3rem; line-height: 1; }

@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
}
