* { box-sizing: border-box; }
:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --green: #16a34a;
  --red: #dc2626;
  --blue: #2563eb;
  --shadow: 0 12px 36px rgba(15, 23, 42, .08);
}
body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
code {
  padding: 2px 5px;
  border-radius: 6px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
}
.wrap {
  width: min(1180px, calc(100vw - 24px));
  margin: 18px auto 48px;
}
.wrap.narrow {
  width: min(480px, calc(100vw - 24px));
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px max(12px, calc((100vw - 1180px) / 2));
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand {
  font-weight: 800;
  letter-spacing: .2px;
}
.muted, .meta {
  color: var(--muted);
  font-size: 13px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
h1, h2 {
  margin: 0 0 14px;
  line-height: 1.2;
}
h1 { font-size: 24px; }
h2 { font-size: 18px; }
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}
.form {
  display: grid;
  gap: 12px;
}
.form.compact {
  gap: 10px;
}
label {
  display: grid;
  gap: 5px;
  color: #374151;
  font-size: 13px;
}
input, textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 11px;
  font: inherit;
  background: #fff;
  color: var(--text);
}
textarea {
  min-height: 120px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.button, .ghost, .mini {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  color: #fff;
  background: var(--blue);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.ghost {
  background: #111827;
  height: 38px;
}
.mini {
  min-width: 58px;
  padding: 7px 10px;
  font-size: 12px;
}
.mini.danger {
  background: var(--red);
}
.alert {
  border-radius: 8px;
  padding: 11px 13px;
  margin: 0 0 14px;
  border: 1px solid transparent;
}
.alert.ok {
  background: #ecfdf5;
  border-color: #bbf7d0;
  color: #166534;
}
.alert.bad {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.alert.code {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
  overflow-wrap: anywhere;
}
.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.checks label,
.feature-cell label {
  display: flex;
  align-items: center;
  gap: 5px;
}
.checks input,
.feature-cell input {
  width: auto;
}
.table {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
th {
  color: var(--muted);
  font-weight: 700;
}
.inline-edit {
  display: contents;
}
.feature-cell {
  min-width: 170px;
}
.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}
.badge.ok {
  background: #dcfce7;
  color: #166534;
}
.badge.bad {
  background: #fee2e2;
  color: #991b1b;
}
.actions {
  display: grid;
  gap: 6px;
  min-width: 70px;
}
.user-cards {
  display: grid;
  gap: 8px;
}
.user-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  overflow: hidden;
}
.user-summary {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 10px 36px 10px 11px;
  list-style: none;
  cursor: pointer;
}
.user-summary::-webkit-details-marker {
  display: none;
}
.user-summary:hover {
  background: #f3f4f6;
}
.user-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.user-meta {
  color: var(--muted);
  font-size: 12px;
}
.user-card[open] .device-chevron {
  transform: translateY(-50%) rotate(90deg);
}
.user-expanded {
  display: grid;
  gap: 9px;
  padding: 11px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.user-toggle {
  width: 100%;
}
.legacy-admin {
  margin-bottom: 16px;
}
.legacy-summary {
  padding: 10px 2px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.legacy-content {
  padding-top: 6px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.device {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fafafa;
  overflow: hidden;
}
.device-details summary {
  list-style: none;
}
.device-details summary::-webkit-details-marker {
  display: none;
}
.device-summary {
  position: relative;
  display: grid;
  gap: 3px;
  padding: 10px 34px 9px 11px;
  cursor: pointer;
}
.device-summary:hover {
  background: #f3f4f6;
}
.device-wxid,
.device-build {
  min-width: 0;
  overflow-wrap: anywhere;
}
.device-wxid {
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.device-build {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.device-label {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.device-chevron {
  position: absolute;
  top: 50%;
  right: 12px;
  font-size: 24px;
  line-height: 1;
  color: #9ca3af;
  transform: translateY(-50%) rotate(0deg);
  transition: transform .16s ease;
}
.device-details[open] .device-chevron {
  transform: translateY(-50%) rotate(90deg);
}
.device-expanded {
  display: grid;
  gap: 5px;
  padding: 10px 11px;
  border-top: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  overflow-wrap: anywhere;
}
.device-expanded code {
  white-space: normal;
  overflow-wrap: anywhere;
}
.device-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 0 11px 10px;
}
.device-actions form {
  min-width: 0;
  margin: 0;
}
.device-actions .mini {
  width: 100%;
}
.device-actions .mini:disabled {
  color: #9ca3af;
  background: #e5e7eb;
  cursor: not-allowed;
}
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .checks { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .panel { padding: 14px; }
  .cards { grid-template-columns: 1fr; gap: 8px; }
  .device-summary { padding-top: 9px; padding-bottom: 8px; }
}
