:root {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    color: #30343b;
    background: #f0f2f5;
}

* { box-sizing: border-box; }
body { margin: 0; padding: 20px 10px; }
h1 { margin: 0 0 22px; font-size: 26px; text-align: center; }
button, input, a { font: inherit; }
button, .link-button { border: 0; border-radius: 8px; cursor: pointer; font-weight: 700; }
button:disabled { cursor: not-allowed; opacity: .5; }
input { width: 100%; padding: 14px; border: 1px solid #c9ced6; border-radius: 8px; font-size: 17px; }
input:focus { border-color: #087bff; outline: 3px solid rgba(8,123,255,.12); }

.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { width: min(100%, 800px); margin: 0 auto; padding: 28px; background: #fff; border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.1); }
.login-card { max-width: 420px; padding: 40px; }
.login-card form { display: grid; gap: 10px; }
.login-card button { width: 100%; padding: 14px; }
.error { min-height: 22px; margin: 8px 0 12px; color: #cf2734; }
.primary { padding: 13px 20px; color: #fff; background: #087bff; }
.success { width: 100%; padding: 15px; color: #fff; background: #24a148; }
.secondary { padding: 10px 16px; color: #263238; background: #e7ebef; }
.danger { padding: 10px 16px; color: #fff; background: #cf2734; }
.compact { flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.page { width: min(100%, 520px); margin: 0 auto; text-align: center; }
.scanner { position: relative; height: 320px; overflow: hidden; margin: 14px 0; border-radius: 10px; background: #000; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scan-area { position: absolute; inset: 15% 20%; border: 3px solid #45d463; border-radius: 10px; box-shadow: 0 0 0 1000px rgba(0,0,0,.45); }
.scan-area span { position: absolute; left: 0; right: 0; height: 3px; background: #45d463; box-shadow: 0 0 9px #45d463; animation: scan 2s linear infinite; }
.camera-controls { position: absolute; top: 9px; right: 9px; display: flex; align-items: center; gap: 7px; }
.camera-controls[hidden] { display: none; }
.camera-button, .zoom-control { padding: 7px 9px; border-radius: 7px; color: #fff; background: rgba(0,0,0,.68); font-size: 13px; font-weight: 700; }
.zoom-control { display: flex; align-items: center; gap: 6px; }
.zoom-control input { width: 92px; padding: 0; border: 0; outline: 0; }
#scan-status { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 9px; color: #fff; background: rgba(0,0,0,.65); }
@keyframes scan { from { top: 0; } to { top: 100%; } }
.result { min-height: 95px; display: grid; place-items: center; padding: 18px; border: 2px dashed #c9ced6; border-radius: 9px; background: #fff; word-break: break-all; }
.status { display: inline-block; margin: 10px 0; padding: 6px 11px; border-radius: 16px; font-size: 14px; font-weight: 700; }
.online { color: #207b3a; background: #e7f7ed; }
.offline { color: #c72b38; background: #fbe9eb; }
.pending { color: #9a6900; background: #fff4ce; }
.controls { display: grid; gap: 10px; }
.input-row { display: flex; gap: 7px; }
.warning { margin: 2px 0; color: #d12835; font-size: 21px; font-weight: 800; }
.qr-panel { margin-top: 22px; }
.qr-panel p:first-child { margin-bottom: 5px; }
.qr-panel img { display: block; margin: auto; background: #fff; }

.receiver-page { min-height: 100vh; padding: 20px; display: flex; justify-content: center; background: #f4f7f9; }
.receiver-container { width: min(100%, 800px); align-self: flex-start; padding: 25px; background: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.receiver-header { display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-bottom: 12px; border-bottom: 1px solid #e2e5e9; }
.receiver-header h1 { margin: 0; color: #333; text-align: left; font-size: 24px; }
.receiver-page .status { margin: 0; padding: 5px 10px; }
.notice { margin: 15px 0; padding: 12px 16px; border-left: 4px solid #4caf50; border-radius: 6px; color: #f11; background: #e8f5e9; box-shadow: 0 2px 4px rgba(0,0,0,.1); text-align: center; font-size: 18px; font-weight: 800; }
.received { padding: 18px; border: 1px solid #d9dee5; border-radius: 8px; background: #f8fafb; }
#latest-code { word-break: break-all; font-family: Consolas, monospace; }
.link-button { display: inline-block; margin-left: 8px; text-decoration: none; }
.guide { margin-top: 10px; color: #000; text-align: left; font-family: SimHei, "Microsoft YaHei", sans-serif; font-weight: 700; line-height: 1.25; }
.guide-image { display: block; width: 100%; height: auto; margin: 15px auto 0; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,.1); }

.admin-card { width: min(100%, 1100px); }
.admin-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.admin-header h1 { margin-bottom: 4px; text-align: left; }
.admin-header p { margin: 0; }
.admin-form { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-top: 24px; }
.admin-form label { display: grid; gap: 7px; font-weight: 700; }
.admin-form .wide { grid-column: 1 / -1; }
.room-search { display: flex; align-items: end; gap: 10px; margin: 20px 0; }
.room-search label { display: grid; flex: 1; gap: 7px; font-weight: 700; }
.room-search button { flex: 0 0 auto; }
.admin-message { min-height: 24px; color: #cf2734; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px; border-bottom: 1px solid #e2e5e9; text-align: left; white-space: nowrap; }
th { background: #f5f7f9; }

@media (max-width: 520px) {
    body { padding: 12px 8px; }
    .card, .login-card { padding: 22px 18px; }
    .scanner { height: 285px; }
    .receiver-page { padding: 0; }
    .receiver-container { padding: 20px 16px; border-radius: 0; box-shadow: none; }
    .receiver-header { align-items: center; }
    .receiver-header h1 { font-size: 21px; }
    .admin-header { align-items: flex-start; }
    .admin-form { grid-template-columns: 1fr; }
    .room-search { align-items: stretch; flex-wrap: wrap; }
    .room-search label { flex-basis: 100%; }
    .admin-form .wide { grid-column: auto; }
}
