* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  margin: 0;
  padding: 0;
  overscroll-behavior-y: contain;
}
.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  /* Respect notches/home-indicator when installed as a standalone PWA */
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  padding-top: max(2rem, env(safe-area-inset-top));
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
}
.wrap.narrow { max-width: 420px; }

/* Desktop: use the extra width available on large screens */
@media (min-width: 1280px) {
  .wrap { max-width: 1120px; }
}

/* Mobile: tighter padding, bigger touch targets, stacked topbar. Buttons
   keep their natural inline sizing (many sit side-by-side in table-row
   actions and pending-request cards) — only size/padding grows, not width,
   so compact inline groups don't get blown apart into a vertical stack. */
@media (max-width: 640px) {
  .wrap { padding: 1.25rem 0.85rem; }
  .card { padding: 1rem; }
  h1 { font-size: 1.3rem; }
  .topbar { flex-direction: column; align-items: stretch; gap: 0.75rem; }
  button, .btn { padding: 0.7rem 1.1rem; font-size: 0.95rem; min-height: 44px; }
  th, td { padding: 0.5rem 0.4rem; font-size: 0.82rem; }
  input, select { min-height: 44px; }
}

/* Standalone action forms (add device, login, signup, renewal) get a
   full-width submit button on mobile for an easier tap target — scoped to
   forms that aren't inline row-actions, via this explicit class rather than
   a blanket selector. */
.form-standalone button { width: 100%; }

/* Table wrapper: horizontal scroll on narrow viewports instead of squashing
   columns or breaking layout — the table keeps its natural width, the
   container scrolls. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; color: #93c5fd; }
.card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.9rem; color: #cbd5e1; }
input, select {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  border: 1px solid #475569;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.95rem;
}
button, .btn {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  border: none;
  background: #2563eb;
  color: white;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
}
button.danger, .btn.danger { background: #dc2626; }
button.secondary, .btn.secondary { background: #475569; }
.error { background: #7f1d1d; border: 1px solid #dc2626; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.notice { background: #14532d; border: 1px solid #16a34a; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid #334155; font-size: 0.9rem; }
th { color: #94a3b8; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; }
.badge { padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge.active { background: #14532d; color: #86efac; }
.badge.expired, .badge.disabled_expired { background: #7c2d12; color: #fdba74; }
.badge.suspended, .badge.removed, .badge.failed { background: #450a0a; color: #fca5a5; }
.badge.provisioning, .badge.pending, .badge.processing, .badge.removing { background: #713f12; color: #fde047; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.topbar form { margin: 0; }
.topbar button { margin: 0; }
a { color: #93c5fd; }
pre.config { background: #0f172a; border: 1px solid #334155; border-radius: 6px; padding: 1rem; font-size: 0.8rem; overflow-x: auto; white-space: pre-wrap; }
.muted { color: #94a3b8; font-size: 0.85rem; }
.honeypot { position: absolute; left: -9999px; }
img.qr { background: white; padding: 8px; border-radius: 6px; margin-top: 0.5rem; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.35rem; vertical-align: middle; }
.dot-online { background: #22c55e; box-shadow: 0 0 4px #22c55e; }
.dot-offline { background: #ef4444; }
