:root {
  color-scheme: light;
  --ink: #18201d;
  --muted: #68736e;
  --paper: #f7f4ec;
  --panel: #fffdf8;
  --line: #d9d1c2;
  --line-strong: #b7a991;
  --green: #116149;
  --green-soft: #dbeee5;
  --brick: #9e3d2d;
  --brick-soft: #f4ded7;
  --blue: #245f9d;
  --shadow: 0 18px 42px rgba(37, 31, 21, .12);
  --radius: 8px;
}

body.dark {
  color-scheme: dark;
  --ink: #edf3ef;
  --muted: #a8b4ae;
  --paper: #111614;
  --panel: #19201d;
  --line: #33413b;
  --line-strong: #596860;
  --green: #7dd8b2;
  --green-soft: #17372c;
  --brick: #ffad9d;
  --brick-soft: #3b201d;
  --blue: #8ab9ee;
  --shadow: 0 18px 42px rgba(0, 0, 0, .32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(24,32,29,.05) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(0deg, rgba(24,32,29,.04) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--paper);
  color: var(--ink);
  font: 15px/1.55 "IBM Plex Sans", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

body.dark {
  background:
    linear-gradient(90deg, rgba(237,243,239,.05) 1px, transparent 1px) 0 0 / 42px 42px,
    linear-gradient(0deg, rgba(237,243,239,.04) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--paper);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 15%, rgba(17,97,73,.12), transparent 24rem),
    radial-gradient(circle at 84% 18%, rgba(158,61,45,.12), transparent 26rem);
  opacity: .75;
}

body.dark::before {
  background:
    radial-gradient(circle at 12% 15%, rgba(125,216,178,.13), transparent 24rem),
    radial-gradient(circle at 84% 18%, rgba(255,173,157,.11), transparent 26rem);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

.shell {
  position: relative;
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark,
.brand-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
}

.mark {
  display: grid;
  place-items: center;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--green);
  color: #fffdf8;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-icon {
  object-fit: contain;
  border-radius: 8px;
}

.brand-copy {
  min-width: 0;
}

.title-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.brand-title {
  margin: 0;
  font-size: clamp(20px, 2.2vw, 31px);
  line-height: 1.05;
  letter-spacing: 0;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--muted);
  background: rgba(255,253,248,.64);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 12px;
  font-weight: 800;
}

body.dark .version-badge {
  background: rgba(17,22,20,.72);
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-toolbar {
  justify-content: flex-end;
  align-items: flex-start;
  gap: 12px 18px;
  min-width: 0;
}

.admin-scope-actions,
.admin-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-scope-actions {
  justify-content: flex-end;
}

.admin-actions {
  justify-content: flex-end;
}

.admin-scope-actions .status-pill {
  max-width: min(360px, 34vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-toolbar {
  justify-content: flex-end;
  align-items: stretch;
  max-width: min(620px, 58vw);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill,
.status-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255,253,248,.76);
  color: var(--muted);
  white-space: nowrap;
}

body.dark .pill,
body.dark .status-pill {
  background: rgba(25,32,29,.82);
}

.status-pill strong {
  color: var(--ink);
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(320px, .78fr);
  gap: 18px;
  align-items: start;
}

.admin-grid {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: rgba(255,253,248,.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

body.dark .panel {
  background: rgba(25,32,29,.91);
}

.panel-header {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.panel-copy {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-body {
  padding: 18px;
}

.stack {
  display: grid;
  gap: 14px;
}

.inline {
  display: flex;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field label,
.check label {
  color: #42504a;
  font-size: 13px;
  font-weight: 700;
}

body.dark .field label,
body.dark .check label {
  color: #d7e1dc;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fffefb;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

body.dark .field input,
body.dark .field select,
body.dark .field textarea {
  background: #111614;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(17,97,73,.13);
}

.field input.input-error,
input.input-error {
  border-color: var(--brick);
  box-shadow: 0 0 0 3px rgba(158,61,45,.16);
}

.field textarea {
  resize: vertical;
  line-height: 1.55;
  outline: none;
}

.field small {
  color: var(--muted);
}

.btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--ink);
  color: #fffdf8;
  font-weight: 800;
  letter-spacing: 0;
}

body.dark .btn {
  background: #edf3ef;
  color: #111614;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: .48;
  transform: none;
}

.btn-secondary {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(17,97,73,.24);
}

.btn-danger {
  background: var(--brick-soft);
  color: var(--brick);
  border: 1px solid rgba(158,61,45,.28);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.message {
  display: none;
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: #fffefb;
  color: var(--ink);
}

body.dark .message,
body.dark .sub-card,
body.dark .metric,
body.dark .check,
body.dark .table-wrap {
  background: #111614;
}

.message.show {
  display: block;
}

.message.error {
  border-color: rgba(158,61,45,.35);
  background: var(--brick-soft);
  color: var(--brick);
}

.message.success {
  border-color: rgba(17,97,73,.32);
  background: var(--green-soft);
  color: var(--green);
}

.message.warning {
  border-color: rgba(181,122,22,.38);
  background: rgba(181,122,22,.13);
  color: #b77b16;
}

.redeem-warning {
  margin-top: 8px;
  color: var(--brick);
  font-weight: 900;
}

.message.subtle {
  color: var(--muted);
}

.purchase-cta {
  min-height: 58px;
  display: grid;
  align-content: center;
  gap: 3px;
  border: 1px solid rgba(17,97,73,.38);
  border-radius: 8px;
  padding: 11px 18px;
  background: linear-gradient(135deg, rgba(17,97,73,.18), rgba(181,122,22,.13));
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.purchase-cta:hover {
  transform: translateY(-1px);
  border-color: rgba(17,97,73,.62);
}

.purchase-cta span {
  color: var(--green);
  font-size: 16px;
  font-weight: 900;
}

.purchase-cta strong {
  color: var(--ink);
  font-size: 13px;
  letter-spacing: 0;
}

.lookup-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.jump-panel {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.jump-label {
  color: var(--green);
  font-size: 13px;
  font-weight: 900;
  text-align: right;
}

.jump-links {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.jump-link,
.jump-more {
  min-height: 44px;
  max-width: 190px;
  display: grid;
  align-content: center;
  gap: 1px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 10px;
  background: rgba(255,253,248,.78);
  text-decoration: none;
}

body.dark .jump-link,
body.dark .jump-more {
  background: rgba(17,22,20,.76);
}

.jump-link span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.jump-link strong {
  color: var(--ink);
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.jump-more {
  color: var(--green);
  font-weight: 900;
}

.announcement-panel {
  margin-top: 18px;
}

.announcement-list {
  display: grid;
  gap: 10px;
}

.announcement-card {
  display: grid;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffefb;
}

body.dark .announcement-card {
  background: #111614;
}

.announcement-card.pinned {
  border-color: rgba(17,97,73,.36);
  background: var(--green-soft);
}

.announcement-title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.announcement-title-line h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.announcement-card p {
  margin: 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.mini-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255,253,248,.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

body.dark .mini-badge {
  background: rgba(17,22,20,.72);
}

.mini-badge.on {
  border-color: rgba(17,97,73,.32);
  background: var(--green-soft);
  color: var(--green);
}

.subscription-list,
.code-output {
  display: grid;
  gap: 10px;
}

.sub-card {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

.balance-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

body.dark .balance-card {
  background: rgba(255, 255, 255, 0.03);
}

.balance-label {
  font-size: 13px;
  color: var(--muted);
}

.balance-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--green);
}

.sub-card.selected {
  border-color: var(--green);
  background: #f5fbf7;
}

body.dark .sub-card.selected {
  background: #17372c;
}

.sub-card input {
  margin-top: 4px;
}

.sub-title {
  margin: 0;
  font-weight: 800;
}

.sub-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

/* F3 兑换历史折叠区 */
.history-section {
  display: grid;
  gap: 8px;
}

.history-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

body.dark .history-toggle {
  background: rgba(255, 255, 255, 0.03);
}

.history-toggle:hover {
  border-color: var(--green);
}

.history-arrow {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}

.history-list {
  display: grid;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
  font-size: 13px;
}

body.dark .history-item {
  background: rgba(255, 255, 255, 0.03);
}

.history-icon {
  font-weight: 700;
}

.history-ok .history-icon {
  color: var(--green);
}

.history-fail .history-icon {
  color: #d64545;
}

.history-when {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.history-kind {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  font-size: 12px;
}

body.dark .history-kind {
  background: rgba(255, 255, 255, 0.08);
}

.history-detail {
  flex: 1;
  min-width: 0;
}

.history-code {
  color: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.history-empty {
  padding: 10px 13px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.metric {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
  min-width: 0;
  overflow: hidden;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 900;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: rgba(247,244,236,.68);
}

body.dark .tabs {
  background: rgba(17,22,20,.68);
}

.tab {
  flex: 1;
  min-height: 38px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.tab.active {
  background: var(--ink);
  color: #fffdf8;
}

body.dark .tab.active {
  background: #edf3ef;
  color: #111614;
}

.tab-view {
  display: none;
}

.tab-view.active {
  display: block;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

.compact-table table {
  min-width: 760px;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.muted-cell {
  color: var(--muted);
  text-align: center;
}

.codes-table-wrap {
  max-height: 560px;
}

.codes-table {
  min-width: 1180px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}

td {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  color: #42504a;
  background: #f3efe4;
  font-weight: 900;
}

body.dark th {
  color: #d7e1dc;
  background: #202923;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr.selected-row {
  background: #f5fbf7;
}

body.dark tbody tr.selected-row {
  background: #17372c;
}

.checks {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.check {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffefb;
  padding: 9px 10px;
}

.settings-block {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: rgba(255,253,248,.58);
}

body.dark .settings-block {
  background: rgba(17,22,20,.54);
}

.settings-block h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.35;
}

.settings-hint {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

.stage-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

body.dark .stage-row {
  background: #111614;
}

.stage-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 6px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--green);
  background: var(--green-soft);
  border: 1px solid rgba(17,97,73,.28);
  white-space: nowrap;
}

.stage-badge-danger {
  color: var(--brick);
  background: var(--brick-soft);
  border-color: rgba(158,61,45,.35);
}

.stage-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.stage-row-final .stage-fields {
  grid-template-columns: minmax(0, 1fr);
}

@media (max-width: 640px) {
  .stage-row {
    grid-template-columns: 1fr;
  }

  .stage-fields {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stage-row-final .stage-fields {
    grid-template-columns: 1fr;
  }
}

.compact-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(78px, auto) minmax(78px, auto);
  gap: 10px;
  align-items: stretch;
}

.compact-inline .check {
  justify-content: center;
  min-width: 78px;
}

.code-box {
  max-height: 240px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151b19;
  color: #eef8ef;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 13px;
}

.code-textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151b19;
  color: #eef8ef;
  padding: 12px;
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

body.dark .code-textarea {
  background: #070908;
}

body.dark .code-box {
  background: #070908;
}

.code-box div {
  padding: 3px 0;
}

.login-wall {
  width: min(420px, calc(100vw - 32px));
  margin: 12vh auto 0;
}

.fake-error {
  width: min(720px, calc(100vw - 32px));
  margin: 8vh 0 0 max(32px, 6vw);
  color: #aeb6bd;
  font-family: "IBM Plex Sans", "Microsoft YaHei", sans-serif;
}

.fake-file {
  position: relative;
  width: 86px;
  height: 100px;
  margin-bottom: 46px;
  border: 0;
  background: transparent;
  cursor: default;
}

.fake-file::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 9px;
  width: 48px;
  height: 62px;
  border: 6px solid #aeb6bd;
  background: #232528;
}

.fake-file::after {
  content: "";
  position: absolute;
  left: 48px;
  top: 9px;
  width: 24px;
  height: 24px;
  border-top: 6px solid #aeb6bd;
  border-right: 6px solid #aeb6bd;
  background: #232528;
  clip-path: polygon(0 0, 100% 100%, 100% 0);
}

.fake-file:focus-visible {
  outline: 2px solid #8ab4f8;
  outline-offset: 8px;
}

.fake-eye,
.fake-mouth,
.fake-ear {
  position: absolute;
  z-index: 1;
  display: block;
}

.fake-eye {
  left: 36px;
  top: 48px;
  width: 8px;
  height: 8px;
  background: #aeb6bd;
}

.fake-mouth {
  left: 35px;
  top: 66px;
  width: 26px;
  height: 12px;
  border-top: 6px solid #aeb6bd;
}

.fake-ear {
  left: 27px;
  top: 27px;
  width: 28px;
  height: 6px;
  background: #aeb6bd;
}

.fake-error h1 {
  margin: 0 0 24px;
  color: #aeb6bd;
  font-size: 34px;
  font-weight: 400;
  line-height: 1.25;
}

.fake-error p {
  margin: 0 0 24px;
  color: #aeb6bd;
  font-size: 20px;
}

.fake-error strong {
  color: #b9c1c9;
  font-weight: 800;
}

.fake-code {
  font-size: 16px !important;
  letter-spacing: .02em;
}

.fake-reload {
  min-height: 54px;
  margin-top: 48px;
  border-radius: 999px;
  padding: 0 28px;
  background: #8ab4f8;
  color: #1f1f1f;
  font-size: 18px;
}

.login-head,
.split-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bulk-bar,
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bulk-bar select,
.bulk-bar input,
.search-bar select,
.search-bar input {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fffefb;
  color: var(--ink);
  padding: 7px 9px;
}

body.dark .bulk-bar select,
body.dark .bulk-bar input,
body.dark .search-bar select,
body.dark .search-bar input {
  background: #111614;
}

.search-bar input {
  flex: 1 1 260px;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 900;
  padding: 0;
}

.sort-btn span {
  color: var(--muted);
  font-family: "IBM Plex Mono", Consolas, monospace;
}

.sort-btn.active span {
  color: var(--green);
}

.link-action {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--green);
  font: inherit;
  font-weight: 900;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-action:hover {
  color: var(--blue);
}

.mono-cell {
  font-family: "IBM Plex Mono", Consolas, monospace;
  font-weight: 700;
  max-width: 210px;
}

.note-cell {
  max-width: 180px;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background: rgba(255,253,248,.64);
  font-weight: 800;
}

.status-tag.unused,
.status-tag.used,
.status-tag.success {
  border-color: rgba(17,97,73,.32);
  background: var(--green-soft);
  color: var(--green);
}

.status-tag.void,
.status-tag.failed,
.status-tag.expired {
  border-color: rgba(158,61,45,.28);
  background: var(--brick-soft);
  color: var(--brick);
}

.mini-action {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 4px 9px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.mini-action.danger {
  color: var(--brick);
  border-color: rgba(158,61,45,.28);
  background: var(--brick-soft);
}

.mini-action:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(0, 0, 0, .48);
  backdrop-filter: blur(8px);
}

.subscription-select-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
}

.subscription-select-option {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  padding: 12px;
  cursor: pointer;
}

.subscription-select-option.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(17,97,73,.14);
}

.subscription-select-option strong,
.subscription-select-option span {
  display: block;
}

.subscription-select-option span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-danger {
  border-color: rgba(158,61,45,.46);
  box-shadow: 0 24px 70px rgba(158,61,45,.26);
}

.modal-danger .modal-header h2,
.modal-danger .modal-body p {
  color: var(--brick);
  font-weight: 900;
}

.modal-wide {
  width: min(760px, 100%);
}

.modal-immersive {
  width: min(80vw, 1180px);
  height: min(80vh, 860px);
  display: flex;
  flex-direction: column;
}

.modal-immersive .modal-body {
  flex: 1;
  overflow: auto;
}

.modal-header {
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
}

.modal-body {
  padding: 18px;
}

.modal-body p {
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 18px 18px;
  flex-wrap: wrap;
}

.danger-text {
  color: var(--brick);
  font-weight: 900;
}

.success-copy {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.65;
}

.image-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

body.dark .image-frame {
  background: #111614;
}

.image-frame img {
  display: block;
  width: 100%;
  max-height: 58vh;
  object-fit: contain;
}

.image-clickable {
  cursor: zoom-in;
}

.modal-immersive .image-frame {
  flex: 1;
  min-height: 0;
}

.modal-immersive .image-frame img {
  height: min(45vh, 520px);
  max-height: none;
}

.modal-jump {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.modal-jump .jump-label {
  text-align: left;
}

.modal-jump .jump-links {
  justify-content: flex-start;
}

.image-preview {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.86);
  padding: 54px 24px 24px;
}

.image-preview img {
  max-width: 96vw;
  max-height: 90vh;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
}

.preview-close {
  position: fixed;
  right: 22px;
  top: 18px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.42);
  background: rgba(0,0,0,.58);
  color: #fff;
  font-weight: 900;
}

.admin-shell {
  width: 100%;
  min-height: 100vh;
  max-width: none;
  padding: 0;
}

.admin-app {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  background:
    linear-gradient(90deg, rgba(24,32,29,.04) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--paper);
}

body.dark .admin-app {
  background:
    linear-gradient(90deg, rgba(237,243,239,.035) 1px, transparent 1px) 0 0 / 42px 42px,
    var(--paper);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255,253,248,.94);
  box-shadow: 10px 0 28px rgba(37,31,21,.08);
}

body.dark .admin-sidebar {
  background: rgba(17,22,20,.96);
  box-shadow: 10px 0 28px rgba(0,0,0,.28);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand .brand-title {
  font-size: 20px;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  padding: 14px 10px;
}

.nav-item {
  min-height: 42px;
  border-radius: 8px;
  padding: 10px 13px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-weight: 900;
}

.nav-item:hover {
  background: rgba(17,97,73,.08);
  color: var(--ink);
}

.nav-item.active {
  background: var(--green-soft);
  color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px 14px 18px;
  border-top: 1px solid var(--line);
}

.sidebar-footer .status-pill {
  width: 100%;
  justify-content: space-between;
}

.sidebar-footer strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-backdrop {
  display: none;
}

.admin-main {
  min-width: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(247,244,236,.9);
  backdrop-filter: blur(12px);
}

body.dark .admin-topbar {
  background: rgba(17,22,20,.9);
}

.admin-page-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.admin-page-title h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.admin-page-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(255,253,248,.76);
  color: var(--ink);
  font-weight: 900;
}

body.dark .icon-btn {
  background: rgba(25,32,29,.8);
}

.menu-btn {
  display: none;
}

.admin-content {
  min-width: 0;
  padding: 22px;
  overflow-x: hidden;
}

.admin-view {
  display: none;
}

.admin-view.active {
  display: grid;
  gap: 18px;
}

.page-grid,
.settings-grid {
  display: grid;
  gap: 18px;
  align-items: start;
  min-width: 0;
}

.two-column {
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
}

.generate-grid {
  grid-template-columns: minmax(340px, 560px) minmax(280px, 1fr);
}

.management-grid {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.settings-grid {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.settings-column {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.settings-security-column {
  align-self: start;
}

.form-grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-narrow {
  max-width: 440px;
}

.full-panel {
  min-width: 0;
}

.admin-app .panel,
.admin-app .stack,
.admin-app .table-wrap {
  min-width: 0;
  max-width: 100%;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-toolbar {
  position: sticky;
  top: 88px;
  z-index: 5;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255,253,248,.94);
  box-shadow: 0 8px 20px rgba(37,31,21,.08);
}

body.dark .table-toolbar {
  background: rgba(17,22,20,.96);
  box-shadow: 0 8px 20px rgba(0,0,0,.22);
}

.codes-table-wrap {
  max-height: calc(100vh - 275px);
  min-height: 320px;
}

.codes-table th:first-child,
.codes-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 48px;
  min-width: 48px;
  max-width: 48px;
  background: #fffefb;
}

.codes-table th:last-child,
.codes-table td:last-child,
.action-table th:last-child,
.action-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  min-width: 92px;
  background: #fffefb;
  box-shadow: -10px 0 16px rgba(37,31,21,.08);
}

.codes-table th:first-child,
.codes-table th:last-child,
.action-table th:last-child {
  z-index: 4;
  background: #f3efe4;
}

body.dark .codes-table th:first-child,
body.dark .codes-table td:first-child,
body.dark .codes-table th:last-child,
body.dark .codes-table td:last-child,
body.dark .action-table th:last-child,
body.dark .action-table td:last-child {
  background: #111614;
}

body.dark .codes-table th:first-child,
body.dark .codes-table th:last-child,
body.dark .action-table th:last-child {
  background: #202923;
}

.codes-table .mono-cell {
  max-width: 260px;
}

.codes-table .note-cell {
  max-width: 220px;
}

.hidden {
  display: none !important;
}

@media (max-width: 860px) {
  .grid,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .inline,
  .metric-row,
  .checks,
  .login-head,
  .split-header {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar {
    width: 100%;
  }

  .user-toolbar {
    max-width: 100%;
  }

  .toolbar-actions,
  .jump-links {
    justify-content: flex-start;
  }

  .jump-label {
    text-align: left;
  }

  .jump-link,
  .jump-more {
    flex: 1 1 148px;
    max-width: none;
  }

  .pill,
  .status-pill {
    max-width: 100%;
    white-space: normal;
  }

  .tabs {
    overflow-x: auto;
  }

  .tab {
    flex: 0 0 auto;
    padding: 0 12px;
  }

  .modal-actions {
    justify-content: stretch;
  }

  .modal-actions .btn {
    flex: 1;
  }

  .modal-immersive {
    width: calc(100vw - 24px);
    height: calc(100vh - 24px);
  }

  .admin-app {
    display: block;
  }

  .admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 70;
    width: min(300px, calc(100vw - 42px));
    transform: translateX(-105%);
    transition: transform .18s ease;
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0 0 0 min(300px, calc(100vw - 42px));
    z-index: 60;
    display: block;
    background: rgba(0,0,0,.48);
    backdrop-filter: blur(5px);
  }

  .admin-topbar {
    align-items: stretch;
    flex-direction: column;
    min-height: 0;
    padding: 12px;
  }

  .admin-page-title {
    width: 100%;
  }

  .admin-toolbar,
  .admin-scope-actions,
  .admin-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .admin-scope-actions .status-pill {
    max-width: 100%;
  }

  .menu-btn {
    display: inline-flex;
    flex: 0 0 42px;
  }

  .admin-content {
    padding: 12px;
  }

  .two-column,
  .generate-grid,
  .management-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    position: static;
  }

  .button-row .btn {
    flex: 1 1 150px;
  }

  .codes-table-wrap {
    max-height: 64vh;
  }
}

/* 关于页 */
.about-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 4px 4px 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.about-logo {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: contain;
  background: var(--green-soft);
  padding: 6px;
}

.about-name {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
}

.about-tagline {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.about-version {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.about-section {
  margin-bottom: 6px;
}

.about-section-title {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
}

.about-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.about-list li {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}

.about-empty {
  color: var(--muted);
  list-style: none;
  margin-left: -20px;
}

/* 备份列表 */
.backup-list {
  display: grid;
  gap: 8px;
}

.backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefb;
}

body.dark .backup-row {
  background: rgba(255, 255, 255, 0.03);
}

.backup-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.backup-type {
  padding: 1px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.05);
  font-size: 12px;
  white-space: nowrap;
}

body.dark .backup-type {
  background: rgba(255, 255, 255, 0.08);
}

.backup-type-prerestore {
  background: #fde8c8;
  color: #8a5a00;
}

.backup-name {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
}

.backup-meta {
  color: var(--muted);
  font-size: 12px;
}

.backup-ops {
  display: flex;
  gap: 6px;
}

.backup-empty {
  padding: 14px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}


/* v0.1.18 批次使用详情 */
.batch-details-modal {
  width: min(1180px, calc(100vw - 40px));
  max-width: 1180px;
}

.batch-details-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.batch-details-summary span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.batch-details-summary strong {
  color: var(--muted);
  font-weight: 600;
}

.batch-details-table-wrap {
  max-height: 58vh;
}

.batch-use-list {
  display: grid;
  gap: 6px;
  min-width: 280px;
}

.batch-use-list > div {
  display: grid;
  grid-template-columns: minmax(80px, auto) minmax(130px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}

.batch-use-list > div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.batch-use-list span,
.batch-use-list time {
  color: var(--muted);
}

@media (max-width: 760px) {
  .batch-details-modal {
    width: calc(100vw - 24px);
  }

  .batch-details-summary {
    grid-template-columns: 1fr;
  }

  .batch-use-list > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}


/* v0.3.4 安全中心/自动充值后台二级导航 */
.subtabs{display:flex;gap:8px;padding:0 0 14px;margin:0 0 18px;border-bottom:1px solid var(--line);overflow-x:auto;scrollbar-width:thin}
.subtab{flex:0 0 auto;border:1px solid var(--line);border-radius:999px;background:transparent;color:var(--muted);padding:7px 13px;font:inherit;font-weight:700;cursor:pointer}
.subtab:hover,.subtab.active{background:var(--green-soft);border-color:var(--green);color:var(--green)}
.recharge-admin-pane{display:none}
.recharge-admin-pane.active{display:block}
#securityTab .table-wrap{margin-top:12px}
#securityTab .card{margin-top:18px;padding:18px}
#securityTab code{display:block;max-width:420px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--muted)}
@media(max-width:700px){#securityTab .toolbar{align-items:stretch}#securityTab .toolbar input,#securityTab .toolbar select,#securityTab .toolbar button{width:100%}.subtabs{padding-bottom:10px}.recharge-admin-pane{min-width:0}}

/* Security center: scoped pagination, IP details and confirmation layout. */
#securityTab .security-pagination{display:flex;align-items:center;justify-content:flex-end;gap:10px;flex-wrap:wrap;margin-top:14px}
#securityTab .security-pagination select{width:auto;min-width:70px}
#securityTab .security-site-label{display:flex;align-items:center;gap:10px}
#securityTab .security-list-heading{margin-top:24px}
#securityTab .table-wrap small{display:block;color:var(--muted);margin-top:4px;overflow-wrap:anywhere}
#securityTab .table-wrap td{vertical-align:top}
#securityTab .security-request-id code{white-space:normal;overflow-wrap:anywhere;max-width:none}
#securityTab .modal textarea{width:100%;resize:vertical}
#securityTab .security-pagination button:disabled{cursor:default;opacity:.5}
#securityTab .security-pagination button:focus-visible,#securityTab .subtab:focus-visible{outline:2px solid var(--green);outline-offset:2px}
#securityTab .sr-only{position:absolute;width:1px;height:1px;padding:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
@media(max-width:700px){#securityTab .security-pagination{justify-content:flex-start}#securityTab .security-site-label{flex-wrap:wrap}#securityTab .modal input,#securityTab .modal textarea,#securityTab .security-pagination select{font-size:16px}}

#securityTab .security-row-actions{display:flex;gap:8px;flex-wrap:wrap}

/* Security filters share the existing form controls and remain usable on mobile. */
#securityTab .security-user-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 12px 0 20px; }
#securityTab .security-user-filters label { display: grid; gap: 6px; flex: 1 1 160px; font-size: 13px; }
#securityTab .security-user-filters input, #securityTab .security-user-filters select { width: 100%; min-width: 0; }
#securityTab .security-risk-state { display: inline-block; margin: 2px 3px 2px 0; }
#securityTab .security-risk-pending { color: #a32f23; font-weight: 600; }
body.dark #securityTab .security-risk-pending { color: #ffb4a6; }

/* Read-only unbind preview: preserve the existing modal and theme. */
#securityTab .security-unbind-preview{border-block:1px solid var(--line);padding-block:14px}
#securityTab .security-unbind-preview h3{margin:0 0 12px}
#securityTab .security-preview-grid{display:grid;grid-template-columns:1fr 1fr;gap:14px;margin:0 0 12px}
#securityTab .security-preview-grid dt{color:var(--muted);margin-bottom:4px}
#securityTab .security-preview-grid dd{margin:0;overflow-wrap:anywhere}
#securityTab .security-preview-grid small{display:block;margin-top:3px}
#securityTab .security-preview-note{font-size:13px;color:var(--muted)}
@media(max-width:600px){#securityTab .security-preview-grid{grid-template-columns:1fr}}
