:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #233d33;
  background: #f4f6f0;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --accent: #315f4e;
  --accent-dark: #234b3b;
  --ink: #233d33;
  --muted: #5f7065;
  --border: #dbe3d8;
  --surface: #ffffff;
  --soft: #edf2e9;
  --danger: #943f38;
  --danger-soft: #fcf0ee;
}

* { box-sizing: border-box; }

body { margin: 0; }

button, input { font: inherit; }

button, a, input { -webkit-tap-highlight-color: transparent; }

button { cursor: pointer; }

button:disabled { cursor: wait; }

a { color: var(--accent-dark); text-underline-offset: 0.2em; }

[hidden], .hidden { display: none !important; }

:focus-visible {
  outline: 3px solid #19715a;
  outline-offset: 4px;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(2rem, env(safe-area-inset-top)) max(1.15rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1.15rem, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 18% 0%, #e7efdf 0, transparent 48%), #f4f6f0;
}

.shell {
  width: min(100%, 43rem);
  margin: 0 auto;
}

.admin-shell { width: min(100%, 77rem); }

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0 0 2rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  font-size: 0.94rem;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.brand-mark {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2.45rem;
  height: 2.45rem;
  border: 1px solid #c6d4c5;
  border-radius: 0.85rem;
  background: #e7eee0;
  color: var(--accent-dark);
}

.brand-mark svg { width: 1.25rem; height: 1.25rem; }

.eyebrow {
  margin: 0 0 0.6rem;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.17em;
  line-height: 1.6;
  text-transform: uppercase;
}

.header-meta { color: var(--muted); font-size: 0.8rem; text-align: right; }

.panel {
  margin-bottom: 1rem;
  padding: clamp(1.35rem, 4vw, 2.25rem);
  border: 1px solid var(--border);
  border-radius: 1.45rem;
  background: var(--surface);
  box-shadow: 0 4px 24px #304b3410;
}

.panel-header { margin-bottom: 1.75rem; }

.title {
  margin: 0 0 0.8rem;
  font-size: clamp(1.75rem, 6vw, 2.35rem);
  line-height: 1.3;
  letter-spacing: -0.035em;
}

.lead {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.85;
  overflow-wrap: anywhere;
}

.section-label { margin: 0 0 0.65rem; font-size: 0.85rem; font-weight: 650; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  padding: 0.3rem 0.65rem;
  border: 1px solid #d1ddcd;
  border-radius: 999px;
  background: #f4f7f0;
  color: #52634f;
  font-size: 0.73rem;
  font-weight: 550;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.badge--success { border-color: #b7d1c2; background: #e8f3eb; color: #2d6044; }

.badge--muted { border-color: #dedfd9; background: #f4f4f1; color: #697065; }

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

.subtle { color: var(--muted); font-size: 0.8rem; line-height: 1.75; }

.stack { display: grid; gap: 1rem; }

.form-grid { display: grid; gap: 1rem; }

.field { display: grid; gap: 0.5rem; min-width: 0; }

.field > label, label.field { font-size: 0.85rem; font-weight: 600; line-height: 1.6; }

.input, .code-input, input[type="text"] {
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid #c9d5c7;
  border-radius: 0.75rem;
  background: #fcfdfb;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input::placeholder, .code-input::placeholder, input[type="text"]::placeholder { color: #6e7b70; opacity: 1; }

.input:focus, .code-input:focus, input[type="text"]:focus { border-color: #438366; }

input:disabled { color: #69756b; background: #f0f3ed; cursor: not-allowed; }

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.85rem;
  max-width: 100%;
  padding: 0.7rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 0.8rem;
  background: var(--soft);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.45;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  transition: background-color 120ms ease, border-color 120ms ease;
}

.button:hover { background: #e1eadb; }

.button--primary { background: var(--accent); color: #fff; }

.button--primary:hover { background: var(--accent-dark); }

.button--secondary { border-color: #d2dccf; background: #f5f8f1; }

.button--danger { border-color: #e4bcb5; background: var(--danger-soft); color: var(--danger); }

.button--danger:hover { background: #f7e1dd; }

.button--quiet { border-color: #d9e0d4; background: #fff; color: var(--muted); }

.button--quiet:hover { background: #f4f7f0; }

.button:disabled { opacity: 0.62; }

.notice {
  padding: 0.8rem 1rem;
  border: 1px solid #d5dfcc;
  border-radius: 0.85rem;
  background: #f5f8f0;
  color: #4f6347;
  font-size: 0.85rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.notice--error { border-color: #e5beb6; background: var(--danger-soft); color: #873b34; }

.notice--success { border-color: #bfd7c5; background: #eef7ee; color: #2e6043; }

.message { margin: 1rem 0 0; }

.pairing-code {
  margin: 1.3rem 0 0.8rem;
  padding: 1.2rem 0.5rem 1.2rem 0.9rem;
  border: 1px solid #d2dfcb;
  border-radius: 1rem;
  background: #f3f7ed;
  color: var(--accent-dark);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.17em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

.pairing-expiry { margin: 0; color: var(--muted); font-size: 0.8rem; line-height: 1.7; }

.divider { height: 1px; margin: 1.4rem 0; border: 0; background: var(--border); }

.details {
  margin: 1.2rem 0 0;
  padding: 1rem 1.05rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: #f8faf5;
  font-size: 0.81rem;
  line-height: 1.8;
}

.details summary { min-height: 1.5rem; color: var(--ink); font-weight: 600; cursor: pointer; }

.details p { margin: 0.75rem 0 0; color: var(--muted); }

.details ul { margin: 0.7rem 0 0; padding-left: 1.25rem; color: var(--muted); }

.details li + li { margin-top: 0.35rem; }

.footer {
  margin: 1.6rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.8;
  text-align: center;
  overflow-wrap: anywhere;
}

.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: start; gap: 1.25rem; }

.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 1.1rem;
}

.section-heading h2 { margin: 0; font-size: 1.08rem; line-height: 1.5; }

.counter { font-size: 0.8rem; font-weight: 500; color: var(--muted); }

.device-list { display: grid; gap: 0.85rem; }

.device-card {
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: #fcfdfb;
}

.device-card--revoked { background: #f7f8f4; }

.device-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.65rem; }

.device-title { margin: 0; font-size: 0.96rem; font-weight: 650; line-height: 1.65; overflow-wrap: anywhere; }

.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 0.8rem; margin: 0.85rem 0; }

.meta-item { margin: 0; color: var(--muted); font-size: 0.75rem; line-height: 1.7; overflow-wrap: anywhere; }

.meta-item dt { color: #61715e; }

.meta-item dd { margin: 0.12rem 0 0; color: var(--ink); }

.approve-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.65rem; margin-top: 1rem; }

.approve-form .field { flex: 1 1 10rem; }

.code-input { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-variant-numeric: tabular-nums; letter-spacing: 0.12em; }

.empty-state { padding: 1.35rem 1rem; border: 1px dashed #ccd8c5; border-radius: 0.95rem; background: #f9fbf6; color: var(--muted); font-size: 0.85rem; line-height: 1.8; text-align: center; }

.status-dot { display: inline-block; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: #46805a; }

@media (max-width: 760px) {
  .page { padding-top: max(1.25rem, env(safe-area-inset-top)); }
  .masthead { margin-bottom: 1.3rem; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .admin-shell > .panel { padding: 1.35rem; }
}

@media (max-width: 420px) {
  .header-meta { max-width: 7rem; font-size: 0.72rem; line-height: 1.6; }
  .brand { gap: 0.55rem; font-size: 0.85rem; }
  .brand-mark { width: 2.2rem; height: 2.2rem; border-radius: 0.75rem; }
  .panel { border-radius: 1.15rem; }
  .actions > .button { flex: 1 1 auto; }
  .device-card { padding: 0.95rem; }
  .device-head { flex-wrap: wrap; }
  .approve-form > .button { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
