:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  color: #15243b;
  background: #f2f5fb;
  font-size: 16px;
  line-height: 1.5;
  --ink: #15243b;
  --nav: #132a4d;
  --primary: #1648ae;
  --primary-hover: #123b8e;
  --muted: #536580;
  --line: #dce4ef;
  --soft: #f2f5fb;
  --white: #fff;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #436fd5; outline-offset: 3px; }
a { color: var(--primary); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.6rem, 3vw, 2.05rem); line-height: 1.25; letter-spacing: .02em; }
h2 { font-size: 1.125rem; line-height: 1.4; }
label { font-size: .875rem; font-weight: 700; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.small-note { color: var(--muted); font-size: .84rem; }
.feedback { margin-top: 12px; font-size: .88rem; overflow-wrap: anywhere; }
.feedback[data-state="error"] { color: #a3222d; }
.feedback[data-state="success"] { color: #176145; }
.feedback[data-state="progress"] { color: var(--muted); }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid #c8d4e5;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--white);
  color: var(--ink);
  font-size: 1rem;
}
textarea { resize: vertical; }
input::placeholder { color: #667891; opacity: 1; }
.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 15px;
  line-height: 1.35;
  font-weight: 700;
  font-size: .9rem;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .14s ease;
}
.primary { background: var(--primary); color: var(--white); }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.secondary { color: var(--ink); background: var(--white); border-color: #c8d4e5; }
.secondary:hover:not(:disabled) { background: #edf3ff; }
.button.link-action { border-color: transparent; color: var(--primary); background: transparent; padding-inline: 4px; }
.button.link-action:hover:not(:disabled) { text-decoration: underline; }
.button.confirm { background: #176145; color: var(--white); }
.button.confirm:hover:not(:disabled) { background: #114b36; }

.login-screen {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 24px;
  background: linear-gradient(145deg, #e6edfa 0%, #f3f6fc 55%, #edf1f7 100%);
}
.login-card {
  width: min(100%, 420px);
  overflow: hidden;
  background: var(--white);
  border: 1px solid #d4dfed;
  border-radius: 18px;
  box-shadow: 0 14px 50px #142b4c15;
}
.login-header { background: var(--nav); color: var(--white); padding: 26px 28px; }
.login-header p { color: #c0d0ed; font-size: .86rem; margin-bottom: 8px; }
.login-form { display: grid; gap: 9px; padding: 25px 28px 28px; }
.login-form input + label { margin-top: 6px; }
.login-form button { margin-top: 13px; justify-self: stretch; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 218px minmax(0, 1fr); }
.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  padding: 24px 16px 18px;
  background: var(--nav);
  color: var(--white);
}
.sidebar-heading { display: flex; align-items: flex-start; flex-direction: column; gap: 8px; padding: 6px 12px 25px; }
.sidebar-title { font-size: 1.25rem; font-weight: 800; letter-spacing: .025em; }
.demo-indicator { color: #c9d9f1; font-size: .76rem; }
.navigation { display: grid; gap: 4px; }
.navigation button, .logout-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 12px;
  color: #e1ebfa;
  background: transparent;
  text-align: left;
  font-size: .93rem;
}
.navigation button:hover, .logout-button:hover { background: #224071; }
.navigation button[aria-current] { background: #315794; color: var(--white); font-weight: 700; }
.sidebar :focus-visible { outline-color: #c1d5ff; }
.logout-button { margin-top: auto; }

.workspace { width: min(100%, 1300px); padding: 32px clamp(20px, 4vw, 48px) 64px; }
.workspace > .feedback { margin: 0 0 15px; }
.view-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 24px; }
.metric {
  padding: 16px 18px;
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--white);
}
.metric span { color: var(--muted); font-size: .9rem; }
.metric strong { font-size: clamp(1.6rem, 4vw, 2.35rem); line-height: 1.3; font-variant-numeric: tabular-nums; color: #163568; }

.panel { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--white); }
.panel-intro {
  display: flex;
  gap: 8px 16px;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 17px 20px 14px;
}
.form-panel { padding: 18px 20px; }
.panel-empty { padding: 20px; color: var(--muted); font-size: .9rem; }
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: .88rem; }
.data-table th, .data-table td { padding: 10px 16px; vertical-align: middle; }
.data-table th { background: #edf2fa; color: #40526e; font-size: .83rem; font-weight: 700; white-space: nowrap; }
.data-table td { border-bottom: 1px solid #e8edf5; overflow-wrap: anywhere; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table td:first-child { font-weight: 700; }
.data-table td[data-number] { font-variant-numeric: tabular-nums; }
.data-table td[data-label="操作"] { text-align: right; }
.cell-main { display: block; }
.cell-sub { color: var(--muted); display: block; font-weight: 400; font-size: .77rem; }

.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.inline-form { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.inline-form .field { width: min(100%, 300px); }
.form-panel > h2 + form { margin-top: 14px; }
.filter-form { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) max-content max-content; gap: 10px; padding: 17px 20px; align-items: end; }
.feedback.inset { margin: 0 20px 12px; }
.pagination { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }
.pagination > div { display: flex; gap: 7px; }
.pagination .button { min-height: 36px; padding: 5px 11px; }

.employee-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 12px; margin-top: 12px; }
#employee-empty { margin-top: 12px; }
.employee-card { display: flex; align-items: flex-start; gap: 17px; padding: 16px; }
.employee-qr {
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.employee-copy { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.employee-copy .button { min-height: 34px; padding: 4px 8px; font-size: .8rem; }
.employee-details { min-width: 0; }
.employee-details h2 { overflow-wrap: anywhere; }
.employee-details p { margin-top: 3px; }

.settings-panels { display: grid; align-items: start; grid-template-columns: minmax(0, .8fr) minmax(0, 1.15fr); gap: 13px; }
.section-intro { margin-bottom: 15px; }
.section-intro p { margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
#activity-form > button[type="submit"], #prize-form > button[type="submit"] { margin-top: 14px; }
.prize-rows { display: grid; gap: 9px; }
.prize-row { display: grid; align-items: end; grid-template-columns: minmax(0, 1fr) minmax(75px, .4fr) max-content; gap: 7px; }
.prize-row label { font-size: .8rem; }
.prize-row .button { padding-inline: 9px; }
.prize-controls { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.probability-total { color: #4c5d75; font-size: .87rem; font-variant-numeric: tabular-nums; }
.probability-total[data-valid="true"] { color: #176145; font-weight: 700; }

.redemption-panel { max-width: 680px; }
.code-input { font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.redemption-result { margin-top: 18px; padding: 18px; border: 1px solid #cbd9eb; border-radius: 10px; background: #f2f6fd; }
.redemption-state { margin-bottom: 4px; font-weight: 700; font-size: .85rem; color: #234980; }
.redemption-state[data-status="redeemed"] { color: #186148; }
.redemption-state[data-status="expired"] { color: #8d3f09; }
.redemption-result h2 { font-size: 1.25rem; overflow-wrap: anywhere; }
.redemption-result dl { display: grid; gap: 7px; margin: 13px 0; }
.redemption-result dl > div { display: grid; grid-template-columns: 5.25rem minmax(0, 1fr); gap: 8px; }
.redemption-result dt { font-size: .84rem; color: var(--muted); }
.redemption-result dd { margin: 0; overflow-wrap: anywhere; font-size: .9rem; }

@media (max-width: 1100px) {
  .settings-panels { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 780px) {
  .admin-shell { display: block; }
  .sidebar {
    z-index: 2;
    min-width: 0;
    height: auto;
    padding: 9px 12px 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
  }
  .sidebar-heading { flex-direction: row; align-items: center; grid-column: 1; grid-row: 1; padding: 7px 4px; }
  .logout-button { grid-column: 2; grid-row: 1; margin: 0; padding: 7px 10px; min-height: 36px; }
  .navigation { grid-row: 2; grid-column: 1 / -1; display: flex; overflow-x: auto; margin: 6px -12px 0; padding: 0 10px 7px; }
  .navigation button { min-height: 37px; padding: 7px 10px; white-space: nowrap; }
  .workspace { padding: 21px 16px 45px; }
  .filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 580px) {
  .metrics { gap: 7px; }
  .metric { padding: 11px 9px; }
  .metric span { font-size: .77rem; }
  .panel-intro, .form-panel, .filter-form, .pagination { padding-inline: 13px; }
  .table-scroll { overflow-x: visible; }
  .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .responsive-table tbody tr { padding: 8px 13px; border-top: 1px solid var(--line); }
  .responsive-table td {
    border: 0;
    display: grid;
    grid-template-columns: minmax(0, 6.2rem) minmax(0, 1fr);
    gap: 6px;
    padding: 4px 0;
  }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-weight: 400; }
  .responsive-table td[data-label="操作"] { text-align: start; }
  .responsive-table td[data-label="操作"]::before { content: ""; }
  .responsive-table td[data-label="操作"] .button { justify-self: start; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .wide { grid-column: 1; }
  .employee-qr { width: 92px; height: 92px; flex-basis: 92px; }
  .employee-card { gap: 11px; padding: 13px; }
}
@media (max-width: 410px) {
  .view-heading { margin-bottom: 14px; }
  .view-heading .button { padding-inline: 9px; }
  .filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-form .field { grid-column: 1 / -1; }
  .login-header, .login-form { padding-inline: 21px; }
  .redemption-result { padding: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .button { transition: none; }
}
