:root {
  color-scheme: light;
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-muted: #eef0ed;
  --text: #1c211f;
  --muted: #626b67;
  --border: #d8ddd9;
  --accent: #176b57;
  --accent-hover: #0f5847;
  --accent-soft: #e6f1ed;
  --danger: #a53a35;
  --danger-soft: #faecea;
  --warning: #8a631a;
  --warning-soft: #f8f1df;
  --shadow: 0 18px 45px rgba(33, 54, 46, 0.08);
  font-family: "Noto Sans SC", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }

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

a { color: inherit; text-decoration: none; }

[hidden] { display: none !important; }

.site-header,
.admin-header {
  min-height: 68px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--text);
  color: #fff;
  font: 700 16px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.claim-shell {
  width: min(980px, calc(100% - 40px));
  min-height: calc(100dvh - 132px);
  margin: 0 auto;
  padding: clamp(54px, 9vh, 96px) 0 72px;
}

.claim-entry { max-width: 720px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1, h2, p { letter-spacing: 0; }

h1 {
  margin: 0 0 30px;
  font-size: clamp(32px, 5vw, 50px);
  line-height: 1.15;
}

h2 { margin: 0; font-size: 22px; line-height: 1.3; }

label {
  display: block;
  margin-bottom: 8px;
  color: #323936;
  font-size: 14px;
  font-weight: 650;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  border: 1px solid #b9c0bc;
  border-radius: 6px;
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 87, 0.15);
}

.claim-form-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.button {
  min-height: 44px;
  padding: 10px 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 700;
  transition: background-color 140ms ease, border-color 140ms ease, transform 100ms ease;
}

.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: 0.65; }

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

.button-secondary {
  border-color: #aeb7b2;
  background: #fff;
  color: #26302c;
}

.button-secondary:hover { background: var(--surface-muted); }

.button-quiet {
  min-height: 38px;
  padding: 7px 12px;
  border-color: var(--border);
  background: #fff;
  color: #333b37;
}

.button-wide { width: 100%; margin-top: 6px; }

.form-error {
  margin: 10px 0 0;
  color: #8f2925;
  font-size: 14px;
  font-weight: 600;
}

.claim-result {
  border-top: 1px solid var(--border);
  padding-top: 28px;
}

.result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.success-text { color: var(--accent); }

.result-meta { margin: 6px 0 0; color: var(--muted); font-size: 13px; }

.result-actions { display: flex; gap: 8px; }

.json-content {
  width: 100%;
  min-height: 340px;
  max-height: 58vh;
  margin: 0;
  padding: 20px;
  overflow: auto;
  border: 1px solid #cdd3cf;
  border-radius: 6px;
  background: #151a18;
  color: #e9eeeb;
  font: 13px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.site-footer {
  min-height: 64px;
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.admin-login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell { width: min(420px, 100%); }
.login-shell > .brand { margin-bottom: 24px; }

.login-panel {
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel h1 { margin-bottom: 26px; font-size: 32px; }
.field { margin-bottom: 18px; }

.admin-header { position: sticky; top: 0; z-index: 20; }

.admin-main {
  width: min(1400px, calc(100% - 48px));
  margin: 0 auto;
  padding: 38px 0 80px;
}

.admin-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.admin-title-row h1 { margin: 0; font-size: 34px; }

.stats-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 34px;
  border-block: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
}

.stats-strip > div {
  min-width: 0;
  padding: 18px 20px;
  border-right: 1px solid var(--border);
}

.stats-strip > div:last-child { border-right: 0; }
.stats-strip span { display: block; color: var(--muted); font-size: 13px; }
.stats-strip strong { display: block; margin-top: 4px; font-size: 26px; }

.notice {
  margin: -14px 0 28px;
  padding: 11px 14px;
  border: 1px solid #b8d1c8;
  border-radius: 6px;
  background: var(--accent-soft);
  color: #124f40;
  font-weight: 600;
}

.notice[data-kind="error"] { border-color: #e4bab6; background: var(--danger-soft); color: #8f2925; }
.notice[data-kind="working"] { border-color: #e2d2a8; background: var(--warning-soft); color: #765313; }

.admin-section { margin-top: 34px; }

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-heading h2 { font-size: 19px; }
.section-heading span { color: var(--muted); font-size: 13px; }

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid #bdc4c0;
  border-bottom: 1px solid #bdc4c0;
  background: var(--surface);
}

table { width: 100%; min-width: 820px; border-collapse: collapse; }

th, td {
  padding: 13px 14px;
  border-bottom: 1px solid #e2e5e3;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th { background: #f7f8f6; color: #4d5652; font-weight: 700; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbf9; }

.table-action { text-align: right; }
.table-actions { display: flex; justify-content: flex-end; gap: 8px; white-space: nowrap; }

.table-button {
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid #c0c7c3;
  border-radius: 5px;
  background: #fff;
  color: #26302c;
  cursor: pointer;
  font-weight: 650;
}

.table-button:hover { border-color: #8e9993; background: #f2f4f2; }
.table-button.danger { color: var(--danger); }

.status {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #f1f3f1;
  color: #4c5551;
  font-size: 12px;
  font-weight: 700;
}

.status-ready { border-color: #ddd0a8; background: var(--warning-soft); color: var(--warning); }
.status-exported { border-color: #b8d1c8; background: var(--accent-soft); color: #145543; }
.status-claimed { border-color: #bad0c7; color: var(--accent); }
.status-expired, .status-revoked { border-color: #e4bab6; background: var(--danger-soft); color: var(--danger); }

.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.subtle { color: var(--muted); font-size: 11px; }

.audit-list { border-top: 1px solid var(--border); }

.audit-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) minmax(180px, 2fr) auto;
  gap: 16px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.audit-row strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.audit-row span, .audit-row time { color: var(--muted); }

@media (max-width: 760px) {
  .site-header, .admin-header { min-height: 60px; padding-inline: 18px; }
  .claim-shell { width: min(100% - 28px, 980px); padding-top: 44px; }
  .claim-form-row { grid-template-columns: 1fr; }
  .claim-form-row .button { width: 100%; }
  .result-heading { flex-direction: column; }
  .result-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .json-content { min-height: 300px; max-height: 50vh; padding: 14px; font-size: 12px; }
  .admin-main { width: min(100% - 28px, 1400px); padding-top: 28px; }
  .admin-title-row { align-items: center; }
  .stats-strip { grid-template-columns: repeat(2, 1fr); }
  .stats-strip > div { border-bottom: 1px solid var(--border); }
  .stats-strip > div:nth-child(2n) { border-right: 0; }
  .stats-strip > div:last-child { border-bottom: 0; }
  .audit-row { grid-template-columns: 1fr; gap: 2px; }
}

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