:root {
  --bg: #eef2f4;
  --bg-deep: #dfe7ea;
  --surface: #f7fafb;
  --ink: #11232b;
  --muted: #63747c;
  --line: #d5e0e4;
  --line-strong: #b7c9cf;
  --card: #ffffff;
  --primary: #12495a;
  --primary-2: #1c6472;
  --accent: #e27a28;
  --accent-soft: #fff0df;
  --primary-soft: #e2f0f3;
  --danger: #bd3e38;
  --danger-soft: #fde9e5;
  --ok: #207354;
  --ok-soft: #e3f4eb;
  --warn: #9c6812;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(18, 44, 54, 0.04), 0 14px 34px rgba(18, 44, 54, 0.08);
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --display: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SF Mono", "Menlo", "Consolas", monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(560px 320px at 100% -5%, rgba(46, 133, 145, 0.14), transparent 68%),
    linear-gradient(180deg, #f7fafb 0%, var(--bg) 42%, var(--bg-deep) 100%);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary-2); text-decoration: none; }

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(244, 245, 247, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.page-loader[hidden] { display: none !important; }
.page-loader-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.page-loader-box .brand-mark {
  width: 44px;
  height: 44px;
  font-size: 13px;
  border-radius: 12px;
}
.page-loader-spin {
  width: 28px;
  height: 28px;
  border: 3px solid #d5dae2;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: pageSpin 0.7s linear infinite;
}
.page-loader-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em;
}
@keyframes pageSpin {
  to { transform: rotate(360deg); }
}

.app-shell {
  width: min(520px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 0 calc(72px + var(--safe-bottom));
  position: relative;
  animation: shellIn 0.4s var(--ease-out) both;
}

@keyframes shellIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* —— 顶栏 —— */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px 13px;
  border-bottom: 1px solid rgba(18, 73, 90, 0.09);
  background: rgba(247, 250, 251, 0.86);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.brand-text {
  min-width: 0;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #0d3d4d 0%, #1b7180 100%);
  color: #f4f7f9;
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.22), 0 7px 16px rgba(18, 73, 90, 0.18);
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  display: block;
  margin-top: 1px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.user-chip {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: 48%;
  flex-shrink: 0;
}
.app-shell.is-user .user-chip {
  max-width: 42%;
}
.role-pill {
  display: block;
  min-width: 0;
  max-width: 100%;
  background: rgba(226, 240, 243, 0.88);
  color: var(--primary);
  border: 1px solid rgba(26, 58, 74, 0.1);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  line-height: 1.2;
}

.page { padding: 16px 16px 28px; }
#queryResult {
  scroll-margin-top: 72px;
}
.page-head {
  margin-bottom: 18px;
  padding: 4px 2px 0;
}
.page-head h2,
.page h2 {
  margin: 0 0 4px;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.page .sub,
.page-head .sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.02em;
}
.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* —— 面板（少用“卡片感”） —— */
.card,
.panel {
  background: var(--card);
  border: 1px solid rgba(18, 73, 90, 0.08);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  animation: riseIn 0.45s var(--ease-out) both;
}
.card:nth-of-type(1), .panel:nth-of-type(1) { animation-delay: 0.03s; }
.card:nth-of-type(2), .panel:nth-of-type(2) { animation-delay: 0.07s; }
.card:nth-of-type(3), .panel:nth-of-type(3) { animation-delay: 0.11s; }

.query-fold {
  padding: 0;
}
.query-fold > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.query-fold > summary::-webkit-details-marker { display: none; }
.query-fold > summary::after {
  content: "展开";
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.query-fold[open] > summary {
  border-bottom: 1px solid var(--line);
}
.query-fold[open] > summary::after {
  content: "收起";
}
.query-fold-body {
  padding: 14px 16px 16px;
}
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--muted);
}
.pager-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-left: auto;
  min-width: 180px;
}
.pager-btns .btn,
.pager-btns .btn + .btn {
  width: 100%;
  margin-top: 0;
  text-align: center;
}
.pager-nums {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}
.pager-num {
  appearance: none;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  line-height: 34px;
  text-align: center;
}
.pager-num.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.pager-num:disabled {
  opacity: 1;
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.field { margin-bottom: 14px; }
.field.field-last,
.field:last-child { margin-bottom: 0; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
  align-items: start;
}
.grid-2 .field { margin-bottom: 0; }
.grid-2 + .field-tip,
.field-tip + .field-tip { margin-top: 0; }
.field-tip + .btn { margin-top: 12px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}
.field input, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #f7fafb;
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}
.field input:focus, .field select:focus {
  border-color: rgba(18, 73, 90, 0.48);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(18, 73, 90, 0.11);
}
.password-wrap {
  position: relative;
}
.password-wrap input {
  padding-right: 44px;
}
.password-eye {
  appearance: none;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 8px;
  cursor: pointer;
}
.password-eye:hover,
.password-eye.on {
  color: var(--primary);
  background: rgba(26, 58, 74, 0.08);
}
.password-eye svg {
  width: 20px;
  height: 20px;
  display: block;
}
.field-tip {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* —— 车牌专业号牌 —— */
.plate-board {
  border: 1px solid rgba(26, 58, 74, 0.18);
  border-radius: 12px;
  padding: 12px;
  background:
    linear-gradient(180deg, #12495a 0%, #0d3d4d 100%);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
.plate-board > .field-tip,
.plate-board #plateTip {
  color: rgba(255,255,255,0.72);
}
.plate-board .field label,
.plate-kind {
  color: rgba(255,255,255,0.78);
}
.plate-kind {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.kind-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0;
  padding: 8px 6px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  font-size: 12px;
  font-weight: 600;
}
.kind-item:has(input:checked),
.kind-item.on {
  background: rgba(196, 92, 38, 0.92);
  border-color: transparent;
  color: #fff;
}
.plate-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.plate-row select,
.plate-slots .plate-slot {
  text-align: center;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.06em;
  background: #f7f8fa;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 4px;
}
.plate-slots {
  display: grid;
  gap: 6px;
}
.plate-slots .plate-slot {
  min-width: 0;
  font-size: 15px;
}

.time-selects {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  align-items: center;
}
.time-colon {
  font-weight: 700;
  color: var(--muted);
}

/* —— 按钮 —— */
.btn {
  appearance: none;
  border: none;
  border-radius: 13px;
  padding: 13px 16px;
  width: 100%;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 7px 16px rgba(18, 73, 90, 0.12);
  transition: transform 0.16s var(--ease-out), background 0.16s ease, opacity 0.16s ease, box-shadow 0.16s ease;
}
.btn:hover { background: var(--primary-2); box-shadow: 0 10px 20px rgba(18, 73, 90, 0.16); }
.btn:active { transform: scale(0.98); }
.btn + .btn { margin-top: 10px; }
.btn.soft {
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: none;
}
.btn.accent {
  background: linear-gradient(135deg, #ed8b35 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: 0 8px 18px rgba(226, 122, 40, 0.24);
}
.btn-verify:hover { background: #a84d1f; }
.btn.danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
  box-shadow: none;
}
.btn.inline {
  width: auto;
  padding: 8px 10px;
  font-size: 13px;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.row-btns { display: flex; gap: 8px; margin-top: 12px; }
.row-btns .btn { margin-top: 0; flex: 1; white-space: nowrap; }
.role-btns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.role-btns .btn {
  flex: none;
  width: 100%;
  min-width: 0;
  padding: 6px 2px;
  font-size: 11px;
  line-height: 1.25;
  white-space: normal;
  border-radius: 8px;
}
.role-btns .btn.role-now-user,
.role-btns .btn.role-now-superuser,
.role-btns .btn.role-now-admin {
  opacity: 1;
  cursor: default;
}
.role-btns .btn.role-now-user,
.role-btns .btn.role-now-user:hover {
  background: #6b7380;
  color: #fff;
}
.role-btns .btn.role-now-superuser,
.role-btns .btn.role-now-superuser:hover {
  background: var(--accent);
  color: #fff;
}
.role-btns .btn.role-now-admin,
.role-btns .btn.role-now-admin:hover {
  background: var(--primary);
  color: #fff;
}
.user-item {
  padding: 12px 12px 10px;
}
.user-item + .user-item {
  margin-top: 8px;
}
.user-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.user-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.user-setpwd,
.user-del,
.user-unlock {
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-size: 11px;
  line-height: 1.3;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.user-setpwd { color: var(--primary-2); }
.user-setpwd:hover { color: var(--primary); text-decoration: underline; }
.user-unlock { color: var(--accent); }
.user-unlock:hover { text-decoration: underline; }
.user-del { color: var(--danger); }
.user-del:hover { text-decoration: underline; }
.user-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  flex: 1;
}
.user-line strong {
  font-size: 14px;
  font-weight: 700;
}
.user-meta {
  margin-top: 4px;
  font-size: 11px;
}
.role-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  line-height: 1.4;
}
.role-tag.user { background: #e8ecf0; color: #5b6570; }
.role-tag.superuser { background: var(--accent-soft); color: var(--accent); }
.role-tag.admin { background: var(--primary-soft); color: var(--primary); }
.role-tag.locked { background: var(--danger-soft); color: var(--danger); }
.role-tag.self { background: #eceff3; color: var(--muted); }

/* —— 登录 —— */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(520px 360px at 80% 15%, rgba(57, 170, 174, 0.3), transparent 62%),
    linear-gradient(160deg, #0b2a37 0%, #12495a 47%, #103744 100%);
}
.auth-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px 320px at 15% 10%, rgba(226, 122, 40, 0.25), transparent 55%),
    radial-gradient(500px 280px at 90% 80%, rgba(255,255,255,0.06), transparent 50%),
    repeating-linear-gradient(
      -18deg,
      transparent 0,
      transparent 11px,
      rgba(255,255,255,0.015) 11px,
      rgba(255,255,255,0.015) 12px
    );
  pointer-events: none;
}
.auth-card {
  width: min(400px, 100%);
  background: rgba(247, 248, 250, 0.96);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 24px;
  padding: 30px 22px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.28);
  position: relative;
  z-index: 1;
  animation: riseIn 0.5s var(--ease-out) both;
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.auth-brand .brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  font-size: 13px;
}
.auth-card h1 {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.auth-card .sub {
  text-align: center;
  margin: 8px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

/* —— 时段格子 —— */
.slot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 76px;
}
.slot-grid .empty { grid-column: 1 / -1; }
.slot-item {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfdfd 0%, #f3f8f9 100%);
  border-radius: 14px;
  padding: 13px 11px;
  min-height: 76px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.16s var(--ease-out);
}
.slot-item .t {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
.slot-item .l {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.slot-item.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #fff7ed 0%, var(--accent-soft) 100%);
  box-shadow: inset 0 0 0 1px rgba(196, 92, 38, 0.2);
}
.slot-item.active .l { color: var(--accent); font-weight: 600; }
.slot-item.disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.slot-item:not(.disabled):active { transform: scale(0.98); }

/* —— 列表 / 徽章 —— */
.list-item {
  background: var(--card);
  border: 1px solid rgba(18, 73, 90, 0.08);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  animation: riseIn 0.4s var(--ease-out) both;
}
.list-item.clickable { cursor: pointer; }
.list-item.clickable.open { border-color: rgba(196, 92, 38, 0.35); }
.list-item .expand-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}
.list-item .head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.list-item .head > div:first-child {
  min-width: 0;
  flex: 1;
}
.list-item .time {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}
.list-item .meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}
.badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge.booked,
.badge.open { background: var(--ok-soft); color: var(--ok); }
.badge.expired { background: var(--danger-soft); color: var(--danger); }
.badge.used { background: #eceff3; color: #6a7380; }
.badge.cancelled { background: #eceff3; color: var(--muted); }

.qr-card {
  margin-top: 12px;
  padding: 16px 14px 14px;
  border-radius: 15px;
  border: 2px solid var(--line-strong);
  background: var(--surface);
  text-align: center;
}
.qr-card.open { border-color: var(--ok); background: #f3faf6; }
.qr-card.expired { border-color: var(--danger); background: #fdf4f3; }
.qr-card.used { border-color: #c5cad3; background: #f2f3f5; }
.qr-wait,
.wait-ahead {
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.02em;
  padding: 8px 12px;
  border-radius: 10px;
  margin: 6px 0 10px;
}
.wait-ahead.is-busy,
.qr-card .wait-ahead.is-busy {
  color: #9a3412;
  background: #ffedd5;
}
.wait-ahead.is-clear,
.qr-card .wait-ahead.is-clear {
  color: var(--ok);
  background: var(--ok-soft);
}
.pallets-hl {
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
  color: #9a3412;
  background: #ffedd5;
  padding: 4px 10px;
  border-radius: 10px;
  vertical-align: middle;
}
.list-item .wait-ahead {
  display: block;
  width: fit-content;
  max-width: 100%;
}
#mineToggleRest {
  margin-top: 4px;
  margin-bottom: 8px;
}
.cat-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 12px;
}
.cat-tabs.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}
.cat-tabs button {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 4px;
  border-radius: 12px;
  line-height: 1.2;
}
.cat-tabs button.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.cat-tabs .cat-count {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  color: inherit;
  opacity: 0.8;
}
#mineRestList[hidden] { display: none; }
.qr-pallets {
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  color: var(--primary);
}
.qr-slot {
  font-family: var(--mono);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}
.qr-status {
  margin-top: 10px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.06em;
}
.qr-card.open .qr-status { color: var(--ok); }
.qr-card.expired .qr-status { color: var(--danger); }
.qr-card.used .qr-status { color: #6a7380; }
.qr-expire {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.qr-box {
  margin-top: 4px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  display: grid;
  place-items: center;
}
.qr-box.hidden { display: none; }
.qr-box img, .qr-box canvas, .qr-box table { margin: 0 auto; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 18px 8px;
  font-size: 13px;
}
.card.empty { box-shadow: none; }

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.admin-grid .btn {
  min-height: 68px;
  display: grid;
  place-items: center;
  text-align: center;
  line-height: 1.3;
  font-size: 15px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  white-space: nowrap;
}
.admin-grid .btn:hover {
  background: var(--primary-2);
  color: #fff;
}
.admin-grid .btn-verify-entry {
  grid-column: 1 / -1;
  min-height: 88px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.16em;
  background: linear-gradient(135deg, #ef913b 0%, var(--accent) 100%);
  color: #fff;
}
.admin-grid .btn-verify-entry:hover {
  background: #a84d1f;
  color: #fff;
}
.admin-grid > .btn:last-child {
  grid-column: 1 / -1;
}
.admin-grid.simple .btn {
  grid-column: 1 / -1;
}
.rule-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.rule-item:last-child { border-bottom: none; }
.rule-item .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.gen-days-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.gen-days-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.gen-days-row input[type="number"] {
  width: 72px;
  margin: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.gen-days-row span {
  color: var(--muted);
  font-size: 13px;
}
.gen-days-row .btn {
  margin-top: 0;
  width: auto;
}
.rule-head { margin-bottom: 8px; }
.max-edit label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.max-edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.max-edit-row input[type="number"] {
  width: 88px;
  margin: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.max-edit-row span {
  color: var(--muted);
  font-size: 13px;
  flex-shrink: 0;
}
.max-edit-row .btn {
  margin-top: 0;
  width: auto;
}
.rule-item.rule-simple,
.rule-item.closed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.rule-item.rule-simple > div:first-child,
.rule-item.closed-row > div {
  min-width: 0;
  flex: 1;
}
.rule-item.rule-simple .btn,
.rule-item.closed-row .btn {
  margin-top: 0;
  flex-shrink: 0;
}

.cal-card { padding: 14px 12px 12px; animation: none; }
.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding: 0 4px;
}
.cal-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.cal-nav {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  font-size: 22px;
  line-height: 1;
  color: var(--primary);
  display: grid;
  place-items: center;
  padding: 0;
}
.cal-nav:active { transform: scale(0.96); }
.cal-week,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}
.cal-week { margin-bottom: 4px; }
.cal-dow {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 0 6px;
}
.cal-day {
  aspect-ratio: 1;
  border: none;
  background: transparent;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.cal-day.is-other,
.cal-day.is-empty {
  color: transparent;
  background: transparent;
  pointer-events: none;
  visibility: hidden;
}
.cal-day.is-past { opacity: 0.55; }
.cal-day.is-open {
  background: #cfead9;
  color: #1a7a48;
}
.cal-day.is-shut {
  background: #f5c9c5;
  color: #b42318;
}
.cal-day.is-part {
  background: #f8e0a4;
  color: #8a5a00;
}
.cal-day.is-today {
  box-shadow: inset 0 0 0 1.5px currentColor;
  font-weight: 700;
}
.cal-day.is-selected {
  box-shadow: inset 0 0 0 2.5px #12495a;
  font-weight: 800;
}
.cal-day.is-selected.is-open { background: #a8dcb8; }
.cal-day.is-selected.is-shut { background: #eea8a2; }
.cal-day.is-selected.is-part { background: #f0c96a; }
.cal-mark {
  font-size: 13px;
  line-height: 1;
  font-weight: 800;
  height: 14px;
}
.cal-day.is-open .cal-mark { color: #1a7a48; }
.cal-day.is-shut .cal-mark { color: #b42318; }
.cal-day.is-part .cal-mark { color: #8a5a00; }
.cal-day.is-other .cal-mark { opacity: 0.55; }

.cal-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.cal-legend-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 0;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.cal-legend-item i {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  font-style: normal;
  font-weight: 800;
  font-size: 12px;
}
.cal-legend-item.is-open i {
  background: #cfead9;
  color: #1a7a48;
}
.cal-legend-item.is-part i {
  background: #f8e0a4;
  color: #8a5a00;
}
.cal-legend-item.is-shut i {
  background: #f5c9c5;
  color: #b42318;
}

.close-fold { padding: 0; animation: none; }
.close-fold-head {
  padding: 16px;
  font-size: 15px;
  font-weight: 700;
  border-bottom: 1px solid var(--line);
}
.close-fold-head em {
  display: block;
  margin-top: 2px;
  font-style: normal;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.close-fold-body { padding: 4px 16px 8px; }
.close-slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.close-slot-row:last-child { border-bottom: none; }
.close-slot-row .time {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 15px;
}
.close-slot-row .meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.close-slot-row .btn {
  margin-top: 0;
  width: auto;
  min-width: 88px;
  flex-shrink: 0;
}

.link-back {
  display: inline-block;
  margin: 8px 0 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-2);
}

/* —— 扫码 —— */
.scan-wrap {
  position: relative;
  margin-top: 10px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.scan-view {
  width: 100%;
  height: 300px;
  background: #111;
  object-fit: cover;
  display: block;
}
.scan-frame {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 58%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 14px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}
.scan-frame::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.35);
  border-radius: 10px;
}
.album-pick { display: none !important; }
.scan-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  text-align: center;
}
.scan-canvas { display: none; }
.scan-decode-video {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 180px;
  height: 120px;
  opacity: 0.05;
  pointer-events: none;
  z-index: 0;
  background: #000;
}

/* —— 底栏 —— */
.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(520px, 100%);
  display: grid;
  gap: 0;
  background: rgba(247, 250, 251, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(18, 73, 90, 0.1);
  padding: 6px 8px calc(8px + var(--safe-bottom));
  z-index: 30;
}
.tabbar button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 11px 4px 9px;
  position: relative;
  letter-spacing: 0.02em;
  transition: color 0.18s ease;
}
.tabbar button::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 4px;
  width: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: translateX(-50%);
  transition: width 0.2s var(--ease-out);
}
.tabbar button.active {
  color: var(--primary);
  font-weight: 800;
}
.tabbar button.active::after { width: 16px; }
.tabbar button:active { transform: scale(0.96); }

/* —— Toast —— */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translateX(-50%) translateY(8px);
  background: rgba(20, 24, 31, 0.92);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s var(--ease-out);
  z-index: 50;
  max-width: min(360px, calc(100% - 32px));
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.confirm-mask {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 24, 31, 0.42);
  display: grid;
  place-items: center;
  padding: 24px 18px;
}
.confirm-mask[hidden] { display: none; }
.confirm-box {
  width: min(360px, 100%);
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 16px 14px;
  box-shadow: 0 18px 48px rgba(20, 24, 31, 0.18);
}
.confirm-msg {
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.confirm-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.confirm-btns .btn { margin-top: 0; }

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

@media (min-width: 600px) {
  .app-shell {
    margin: 18px auto 0;
    min-height: calc(100vh - 18px);
    border-radius: 26px 26px 0 0;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(18, 73, 90, 0.06), 0 20px 60px rgba(18, 44, 54, 0.1);
    background: rgba(247, 250, 251, 0.48);
  }
  .topbar { border-radius: 26px 26px 0 0; }
}
