:root {
  color-scheme: light;
  --ink: #17202f;
  --muted: #687386;
  --line: #dfe4ec;
  --soft: #f5f7fa;
  --surface: #ffffff;
  --nav: #121826;
  --nav-soft: #1d2636;
  --gold: #ba8a3a;
  --gold-deep: #8d6428;
  --blue: #356bd8;
  --green: #23805b;
  --orange: #b85d20;
  --red: #bd3c4b;
  --purple: #6e55a5;
  --radius: 12px;
  --shadow: 0 18px 48px rgba(30, 43, 66, .10);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--soft); color: var(--ink); }
body { font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(420px, .75fr); background: var(--surface); }
.login-brand { min-height: 100dvh; padding: clamp(32px, 6vw, 96px); display: flex; flex-direction: column; justify-content: center; color: #f5f2eb; background: radial-gradient(circle at 78% 18%, rgba(186,138,58,.26), transparent 25%), linear-gradient(145deg, #121826, #1c2940 72%, #232d3f); }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.38); border-radius: 50%; color: #f0d4a0; font-weight: 750; letter-spacing: .12em; }
.brand-mark.small { width: 38px; height: 38px; font-size: 12px; flex: 0 0 auto; }
.brand-kicker, .section-label { margin: 28px 0 10px; color: #d9b675; font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.login-brand h1 { max-width: 820px; margin: 0; font-size: clamp(38px, 5vw, 72px); line-height: 1.08; letter-spacing: -.045em; }
.login-brand > p:not(.brand-kicker) { max-width: 620px; margin: 24px 0 0; color: #bcc5d4; font-size: 17px; line-height: 1.7; }
.event-meta { display: flex; gap: 28px; margin-top: 62px; color: #e6dfd1; font-variant-numeric: tabular-nums; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-form { width: min(100%, 380px); display: grid; gap: 22px; }
.login-form h2 { margin: 0; font-size: 30px; }
.login-form .section-label { margin: 0 0 8px; color: var(--gold-deep); }
.muted { color: var(--muted); }
label { display: grid; gap: 8px; color: #3e495b; font-weight: 650; }
input, select, textarea { width: 100%; border: 1px solid #cbd3df; border-radius: 9px; background: #fff; color: var(--ink); padding: 11px 12px; outline: none; transition: border-color .18s ease, box-shadow .18s ease; }
textarea { min-height: 92px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #8993a3; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,107,216,.16); }
.button { border: 0; border-radius: 9px; padding: 10px 16px; font-weight: 700; white-space: nowrap; transition: transform .12s ease, background .16s ease; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--nav); color: #fff; }
.button-primary:hover { background: #26344b; }
.button-gold { background: var(--gold); color: #17120b; }
.button-secondary { border: 1px solid #cbd3df; background: #fff; color: var(--ink); }
.button-danger { background: #fff0f1; color: #9a2936; border: 1px solid #f0bfc5; }
.button-large { min-height: 48px; }
.button-small { padding: 7px 10px; font-size: 12px; }
.text-button, .icon-button { border: 0; background: transparent; color: inherit; padding: 8px; }
.form-error { min-height: 20px; margin: -8px 0; color: var(--red); }

.app-view { min-height: 100dvh; display: grid; grid-template-columns: 230px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; padding: 18px 14px; background: var(--nav); color: #e6ebf2; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 2px 8px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sidebar-brand div { display: grid; gap: 2px; }
.sidebar-brand small { color: #8895aa; }
.sidebar nav { display: grid; gap: 3px; padding: 16px 0; }
.nav-group { margin: 16px 10px 6px; color: #78879e; font-size: 11px; font-weight: 700; }
.nav-item { display: flex; align-items: center; min-height: 39px; padding: 8px 11px; border: 0; border-radius: 8px; background: transparent; color: #bbc5d4; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--nav-soft); color: #f3d59f; box-shadow: inset 3px 0 var(--gold); }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 12px; color: #9ca8ba; }
.app-main { min-width: 0; }
.topbar { height: 68px; position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); backdrop-filter: blur(12px); }
.event-title, .user-summary { display: flex; align-items: center; gap: 10px; }
.user-summary { flex-direction: column; align-items: flex-end; gap: 2px; }
.user-summary small { color: var(--muted); }
.menu-button { display: none; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px 10px; }
#page { max-width: 1540px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.035em; }
.page-head p { margin: 8px 0 0; color: var(--muted); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar input { width: 240px; min-height: 39px; }

.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.metric { min-width: 0; padding: 18px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 8px; font-size: clamp(22px, 2.3vw, 32px); font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.metric small { display: block; margin-top: 4px; color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(340px, .55fr); gap: 18px; margin-top: 18px; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 6px 24px rgba(35,46,66,.035); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 18px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 16px; }
.panel-body { padding: 18px; }
.target-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line); }
.target-item { background: #fff; padding: 20px; }
.target-item strong { display: block; margin: 10px 0 7px; font-size: 26px; }
.target-item span, .target-item small { color: var(--muted); }
.mini-bar { height: 5px; margin-top: 13px; background: #e9edf3; border-radius: 4px; overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--gold); }
.alert-list { display: grid; gap: 1px; background: var(--line); }
.alert-row { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; background: #fff; }
.alert-row strong { font-size: 18px; }
.rank-list { display: grid; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 30px minmax(110px,1fr) 1fr 1fr 1fr; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #edf0f4; }
.rank-row:last-child { border-bottom: 0; }
.rank-no { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; background: #edf0f4; font-weight: 700; }
.rank-row:nth-child(1) .rank-no { background: #f4dfb8; }
.rank-cell { display: grid; gap: 2px; }
.rank-cell small { color: var(--muted); }

.data-shell { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.table-wrap { overflow: auto; max-height: calc(100dvh - 220px); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { position: sticky; top: 0; z-index: 2; padding: 12px 13px; background: #f7f8fa; color: #596577; font-size: 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
td { padding: 12px 13px; border-bottom: 1px solid #edf0f4; white-space: nowrap; vertical-align: middle; }
tbody tr:hover { background: #fafbfc; }
.table-empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.table-actions { display: flex; gap: 6px; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 15px; color: var(--muted); border-top: 1px solid var(--line); }

.status { display: inline-flex; align-items: center; justify-content: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-green { background: #e7f4ee; color: #176a4b; }
.status-blue { background: #e9f0ff; color: #2d5fbd; }
.status-orange { background: #fff0e4; color: #98501f; }
.status-red { background: #fdebed; color: #a52d3b; }
.status-gray { background: #edf0f4; color: #657083; }
.status-purple { background: #eeeafd; color: #604b99; }

.checkin-layout { display: grid; grid-template-columns: minmax(340px,.72fr) minmax(0,1.28fr); gap: 18px; }
.checkin-search { padding: 20px; }
.checkin-search input { font-size: 18px; min-height: 52px; }
.search-results { display: grid; gap: 8px; margin-top: 14px; }
.customer-result { width: 100%; display: flex; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 12px; text-align: left; }
.customer-result.selected { border-color: var(--gold); background: #fffaf1; }
.customer-result small { color: var(--muted); }
.checkin-card { padding: 20px; }
.participant-list { display: grid; gap: 8px; margin: 18px 0; }
.participant-option { grid-template-columns: 22px 1fr auto; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px; }
.participant-option input { width: 18px; }
.quick-flags { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.quick-flags label { grid-template-columns: 20px 1fr; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
.quick-flags input { width: 16px; }
.room-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; }
.room-card { border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 14px; }
.room-card strong { font-size: 18px; }
.room-card p { margin: 8px 0 0; color: var(--muted); }

.modal { position: fixed; inset: 0; z-index: 100; display: grid; grid-template-columns: 1fr minmax(420px, 600px); }
.modal-backdrop { background: rgba(13,19,29,.48); }
.modal-panel { height: 100dvh; background: #fff; overflow-y: auto; box-shadow: var(--shadow); }
.modal-panel > header { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.96); }
.modal-panel h2, .modal-panel .section-label { margin: 0; }
#modal-form { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; padding: 24px; }
#modal-form .field-wide { grid-column: 1 / -1; }
.form-actions { position: sticky; bottom: 0; grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; margin: 10px -24px -24px; padding: 16px 24px; border-top: 1px solid var(--line); background: #fff; }
.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: grid; gap: 9px; }
.toast { min-width: 260px; max-width: 420px; padding: 13px 15px; border-radius: 9px; background: var(--nav); color: #fff; box-shadow: var(--shadow); }
.toast.error { background: #8f2934; }
.skeleton { min-height: 18px; border-radius: 6px; background: linear-gradient(90deg,#eef1f5,#f8f9fb,#eef1f5); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(3,1fr); }
  .metric:nth-child(3) { border-right: 0; }
  .metric:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .target-grid { grid-template-columns: repeat(2,1fr); }
  .room-grid { grid-template-columns: repeat(3,1fr); }
}

@media (max-width: 820px) {
  .login-view { grid-template-columns: 1fr; }
  .login-brand { min-height: auto; padding: 38px 24px; }
  .login-brand h1 { font-size: 36px; }
  .event-meta { margin-top: 30px; }
  .login-panel { padding: 38px 24px; }
  .app-view { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; transform: translateX(-100%); width: 250px; transition: transform .2s ease; box-shadow: 20px 0 50px rgba(0,0,0,.22); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: block; }
  .topbar { padding: 0 14px; }
  .event-title strong { display: none; }
  #page { padding: 18px 14px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .toolbar { width: 100%; }
  .toolbar input { width: 100%; flex: 1 1 100%; }
  .checkin-layout { grid-template-columns: 1fr; }
  .room-grid { grid-template-columns: repeat(2,1fr); }
  .modal { grid-template-columns: 1fr; }
  .modal-backdrop { display: none; }
  .modal-panel { width: 100%; }
}

@media (max-width: 560px) {
  .login-brand h1 { font-size: 30px; }
  .metrics { grid-template-columns: repeat(2,1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .metric:nth-child(2n) { border-right: 0; }
  .target-grid { grid-template-columns: 1fr; }
  .rank-row { grid-template-columns: 28px 1fr 1fr; }
  .rank-row .rank-cell:nth-child(n+4) { display: none; }
  .room-grid { grid-template-columns: 1fr; }
  #modal-form { grid-template-columns: 1fr; }
  #modal-form .field-wide { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
