:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #15202b;
  --muted: #667085;
  --line: #d8dee6;
  --primary: #1769aa;
  --primary-dark: #105184;
  --danger: #c43d35;
  --ok: #16804b;
  --shadow: 0 18px 45px rgba(23, 38, 58, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 16px;
}

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

button:active {
  transform: translateY(1px);
}

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 10px 11px;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

textarea {
  resize: vertical;
}

.front-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.front-shell {
  width: min(880px, 100%);
}

.qr-panel {
  display: grid;
  grid-template-columns: minmax(240px, 360px) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: clamp(20px, 5vw, 44px);
}

.qr-image-wrap {
  display: grid;
  place-items: center;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
}

.qr-image {
  display: block;
  width: min(280px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
}

.empty-state {
  color: var(--muted);
  font-weight: 700;
}

.qr-copy h1 {
  margin: 0 0 14px;
  font-size: clamp(26px, 5vw, 42px);
  letter-spacing: 0;
}

.qr-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.admin-page {
  padding: 24px;
}

.auth-locked #managerPanel,
.auth-locked #accountMenu {
  display: none !important;
}

.admin-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.admin-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: 0;
}

.admin-header p {
  margin: 0;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.account-menu {
  position: relative;
}

.account-button {
  min-width: 118px;
}

.account-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: min(320px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.account-dropdown::before {
  position: absolute;
  top: -6px;
  right: 24px;
  width: 10px;
  height: 10px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  background: var(--panel);
  content: "";
  transform: rotate(45deg);
}

.account-form {
  display: grid;
  gap: 12px;
}

.account-form h2 {
  margin: 0;
  font-size: 16px;
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost-button:hover {
  border-color: var(--primary);
  background: #eef6fc;
  color: var(--primary);
}

.danger-outline {
  width: 100%;
  margin-top: 12px;
  border: 1px solid rgba(196, 61, 53, 0.35);
  background: #fff;
  color: var(--danger);
}

.danger-outline:hover {
  border-color: var(--danger);
  background: rgba(196, 61, 53, 0.08);
  color: var(--danger);
}

.manager-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.manager-stack {
  display: grid;
  gap: 18px;
}

.manager-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(23, 38, 58, 0.07);
  padding: 18px;
}

.compact-panel {
  width: min(420px, 100%);
}

.manager-panel h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

.login-form,
.create-panel {
  display: grid;
  gap: 14px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.switch-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

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

.section-title h2 {
  margin: 0;
}

.section-title span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.item-list {
  display: grid;
  gap: 12px;
}

.list-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 28px;
  text-align: center;
}

.qr-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.row-thumb {
  width: 132px;
  height: 132px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fafb;
  object-fit: contain;
}

.row-form {
  display: grid;
  gap: 10px;
}

.row-top,
.row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  background: rgba(22, 128, 75, 0.11);
  color: var(--ok);
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
}

.status-pill.disabled {
  background: rgba(102, 112, 133, 0.12);
  color: var(--muted);
}

.danger-text {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--danger);
  padding: 0;
}

.danger-text:hover {
  background: transparent;
  color: #9f211b;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10;
  max-width: min(340px, calc(100vw - 40px));
  border-radius: 8px;
  background: #101828;
  color: #fff;
  font-weight: 700;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .front-page,
  .admin-page {
    padding: 14px;
  }

  .qr-panel,
  .manager-grid,
  .qr-row {
    grid-template-columns: 1fr;
  }

  .admin-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .account-dropdown {
    left: auto;
    right: 0;
  }

  .qr-image-wrap {
    min-height: 240px;
  }

  .row-thumb {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }
}
