:root {
  --paper: #f6f7f5;
  --surface: #ffffff;
  --ink: #1c2528;
  --muted: #697477;
  --line: #dde2df;
  --line-strong: #bcc6c1;
  --navy: #182a32;
  --blue: #2563eb;
  --blue-soft: #edf4ff;
  --green: #157458;
  --green-soft: #e8f5ef;
  --amber: #93641a;
  --amber-soft: #fbf2df;
  --red: #a43e39;
  --red-soft: #fbeceb;
  --sans: Calibri, "Noto Sans SC", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--paper); color: var(--ink); font: 15px/1.65 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid rgba(37, 99, 235, .25); outline-offset: 2px; }

.admin-topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: 66px; padding: 12px clamp(18px, 4vw, 42px);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: var(--navy); color: #fff; border-bottom: 3px solid #35505a;
}
.access-brand { display: flex; align-items: center; gap: 12px; }
.access-brand > span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.access-brand strong { font-family: var(--serif); font-size: 17px; letter-spacing: .02em; }
.access-brand small { margin-top: 4px; color: #b8c6ca; font: 9px/1 var(--mono); letter-spacing: .22em; }
.web-mark {
  position: relative; width: 34px; height: 38px; border: 1px solid #769099;
  background: #f8faf9; border-radius: 3px 3px 7px 3px; box-shadow: 5px 5px 0 #29424b;
}
.web-mark::before, .web-mark::after { content: ""; position: absolute; left: 7px; right: 7px; height: 2px; background: #7d8f94; box-shadow: 0 6px 0 #7d8f94, 0 12px 0 #7d8f94; }
.web-mark::before { top: 8px; }
.web-mark::after { top: 26px; right: 16px; box-shadow: none; background: var(--blue); }
.admin-top-actions { display: flex; align-items: center; gap: 10px; }

.admin-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 32px 0 64px; }
.admin-auth-card {
  width: min(440px, 100%); margin: 7vh auto 0; padding: 30px;
  background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--navy);
  border-radius: var(--radius); box-shadow: 0 16px 40px rgba(24, 42, 50, .08);
}
.admin-auth-card h1 { margin: 0 0 8px; font: 600 25px/1.3 var(--serif); }
.admin-auth-card > p:not(.access-kicker) { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
.access-kicker { margin: 0 0 6px; color: var(--blue); font: 700 10px/1.3 var(--mono); letter-spacing: .18em; text-transform: uppercase; }

.admin-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.admin-heading h1 { margin: 0; font: 600 clamp(24px, 3vw, 31px)/1.2 var(--serif); }
.admin-heading-lead { margin: 7px 0 0; color: var(--muted); font-size: 13.5px; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.admin-stats article { min-height: 92px; padding: 16px 20px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); }
.admin-stats article:last-child { border-right: 0; }
.admin-stats span { color: var(--muted); font-size: 12px; }
.admin-stats strong { font: 600 28px/1 var(--mono); }

.admin-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-strong); margin-bottom: 18px; overflow-x: auto; }
.admin-tabs button { padding: 10px 18px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 600; white-space: nowrap; }
.admin-tabs button:hover { color: var(--ink); }
.admin-tabs button.is-active { color: var(--blue); border-bottom-color: var(--blue); }

.admin-panel { padding: clamp(18px, 3vw, 28px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 18px rgba(24, 42, 50, .04); }
.admin-panel-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 20px; }
.admin-panel-head h2 { margin: 0 0 3px; font: 600 19px/1.4 var(--serif); }
.admin-panel-head p { margin: 0; color: var(--muted); font-size: 13px; }
.admin-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-filter { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; }
.admin-filter input, .admin-filter select { min-width: 160px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink); }

.access-form { display: flex; flex-direction: column; gap: 14px; }
.access-form label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; }
.access-form label > span { color: var(--ink); font-weight: 600; }
.access-form input, .access-form select {
  width: 100%; padding: 10px 12px; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 7px;
}
.access-form input:focus, .access-form select:focus, .admin-filter input:focus, .admin-filter select:focus { border-color: var(--blue); outline: 0; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.access-primary, .access-secondary, .access-danger {
  display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 8px 16px;
  border-radius: 7px; border: 1px solid transparent; font-weight: 600; transition: background .15s, border-color .15s;
}
.access-primary { background: var(--blue); color: #fff; }
.access-primary:hover { background: #1d4ed8; }
.access-primary:disabled { opacity: .55; cursor: progress; }
.access-primary.is-compact { min-height: 34px; padding: 6px 13px; font-size: 13px; }
.access-secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.access-secondary:hover { background: #f2f5f3; }
.access-danger { background: var(--red-soft); color: var(--red); border-color: #efcfcd; }
.access-danger:hover { background: #f6deda; }
.admin-top-actions .access-secondary { background: transparent; color: #fff; border-color: #657d85; }
.admin-top-actions .access-secondary:hover { background: #29424b; }

.access-notice { margin: 0 0 18px; padding: 11px 14px; border: 1px solid var(--line-strong); border-left-width: 4px; border-radius: 7px; background: #fff; color: var(--muted); }
.access-notice.is-success { border-color: #9fd0bb; background: var(--green-soft); color: var(--green); }
.access-notice.is-error { border-color: #e5b9b6; background: var(--red-soft); color: var(--red); }
.access-notice.is-info { border-color: #b9cff4; background: var(--blue-soft); color: #27549f; }

.admin-record-list { display: flex; flex-direction: column; gap: 11px; }
.admin-record { position: relative; padding: 16px 18px 16px 22px; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.admin-record::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--line-strong); }
.admin-record.is-pending::before { background: var(--amber); }
.admin-record.is-approved::before { background: var(--green); }
.admin-record.is-rejected::before { background: var(--red); }
.admin-record-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.admin-record-identity { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.admin-record h3 { margin: 0; font: 600 16px/1.4 var(--serif); }
.admin-record time { color: var(--muted); font: 11px/1.5 var(--mono); white-space: nowrap; }
.admin-status { padding: 2px 8px; border-radius: 99px; background: #edf0ee; color: var(--muted); font-size: 10px; font-weight: 700; }
.admin-status.is-pending { background: var(--amber-soft); color: var(--amber); }
.admin-status.is-approved { background: var(--green-soft); color: var(--green); }
.admin-status.is-rejected { background: var(--red-soft); color: var(--red); }
.admin-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 9px 18px; margin: 13px 0 0; }
.admin-meta > div { min-width: 0; }
.admin-meta dt { color: var(--muted); font-size: 10px; letter-spacing: .04em; }
.admin-meta dd { margin: 2px 0 0; font: 12px/1.5 var(--mono); overflow-wrap: anywhere; }
.admin-message { margin-top: 12px; padding: 9px 11px; background: #f7f8f6; border: 1px solid #ebeeeb; border-radius: 6px; }
.admin-message span { color: var(--muted); font-size: 10px; }
.admin-message p { margin: 3px 0 0; white-space: pre-wrap; font-size: 13px; }
.admin-record-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-top: 13px; }
.admin-grant { padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; font-size: 13px; }
.admin-revoked-time, .admin-user-agent { margin: 11px 0 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.admin-empty { padding: 34px 18px; text-align: center; color: var(--muted); background: #fafbf9; border: 1px dashed var(--line-strong); border-radius: 8px; }
.admin-empty strong { display: block; color: var(--ink); font: 600 16px/1.5 var(--serif); }
.admin-empty p { margin: 4px 0 0; font-size: 12px; }

.admin-allowlist-form { margin-bottom: 20px; padding: 16px; background: #f8faf8; border: 1px solid var(--line); border-radius: 8px; }
.admin-allowlist-fields { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; }
.admin-form-note { margin: 0; color: var(--muted); font-size: 11px; }
.admin-password-form { max-width: 460px; }

@media (max-width: 820px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-stats article:nth-child(2) { border-right: 0; }
  .admin-stats article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .admin-allowlist-fields { grid-template-columns: 1fr; }
  .admin-allowlist-fields button { width: 100%; }
}
@media (max-width: 560px) {
  .admin-topbar, .admin-heading, .admin-record-head { align-items: flex-start; flex-direction: column; }
  .admin-top-actions, .admin-heading > button { width: 100%; }
  .admin-top-actions > * { flex: 1; }
  .admin-shell { width: min(100% - 20px, 1180px); padding-top: 18px; }
  .admin-stats article { padding: 13px; min-height: 78px; }
  .admin-stats strong { font-size: 23px; }
  .admin-panel { padding: 14px; }
  .admin-filters, .admin-filter { width: 100%; }
  .admin-filter input, .admin-filter select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
