/* ============================
   基础重置
   ============================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --green: #07c160;
  --green-light: #e8f7ee;
  --green-dark: #06ad56;
  --blue: #576b95;
  --blue-light: #eef0f6;
  --blue-dark: #4a5c80;
  --purple: #8b5cf6;
  --purple-light: #f0ebff;
  --purple-dark: #7c3aed;
  --orange: #f59e0b;
  --red: #ef4444;
  --gray-1: #f7f7f7;
  --gray-2: #e5e5e5;
  --gray-3: #999;
  --gray-4: #333;
  --bg: #ededed;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  color: var(--gray-4);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

input, button { font-family: inherit; font-size: inherit; }
a { text-decoration: none; color: inherit; }

/* ============================
   App 容器
   ============================ */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

.admin-app {
  max-width: 768px;
}

.screen {
  display: none;
  min-height: 100vh;
}
.screen.active {
  display: block;
}

/* ============================
   入口页
   ============================ */
.portal-page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: linear-gradient(180deg, #f0f4f8 0%, #e8ecef 100%);
}

.portal-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-4);
  margin-bottom: 4px;
}

.portal-subtitle {
  font-size: 14px;
  color: var(--gray-3);
  margin-bottom: 40px;
}

.portal-cards {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 320px;
}

.portal-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  transition: transform 0.15s, box-shadow 0.15s;
}
.portal-card:active {
  transform: scale(0.97);
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}

.portal-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.portal-name {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.portal-desc {
  font-size: 13px;
  color: var(--gray-3);
  text-align: center;
  line-height: 1.5;
}

.portal-queue {
  border-top: 4px solid var(--green);
}
.portal-admin {
  border-top: 4px solid var(--blue);
}

.portal-footer {
  margin-top: 40px;
  font-size: 12px;
  color: var(--gray-3);
}

/* ============================
   登录页
   ============================ */
.login-header {
  padding: 60px 24px 32px;
  text-align: center;
}
.login-header h1 {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-header p {
  font-size: 14px;
  color: var(--gray-3);
}

.form-section {
  padding: 0 24px;
}

.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--gray-4);
}
.form-group input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--gray-2);
  border-radius: 10px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}
.form-group input:focus {
  border-color: var(--green);
}

/* ============================
   按钮
   ============================ */
.btn-primary {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn-primary:active { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-large {
  width: 100%;
  padding: 14px;
  font-size: 17px;
  margin-top: 8px;
}

.btn-secondary {
  background: #fff;
  color: var(--gray-4);
  border: 1.5px solid var(--gray-2);
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  cursor: pointer;
}
.btn-secondary:active { background: var(--gray-1); }

.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  cursor: pointer;
}
.btn-danger:active { opacity: 0.85; }

.btn-small {
  background: #fff;
  color: var(--gray-4);
  border: 1.5px solid var(--gray-2);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.btn-small:active { background: var(--gray-1); }

.btn-danger-outline {
  border-color: var(--red);
  color: var(--red);
}

.btn-secondary-outline {
  background: transparent;
  border: 1.5px solid var(--gray-2);
  color: var(--gray-3);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.btn-warn-outline {
  background: transparent;
  border: 1.5px solid var(--orange);
  color: var(--orange);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.btn-success {
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.btn-tiny {
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

/* ============================
   提示文字
   ============================ */
.tips {
  margin-top: 24px;
  padding: 16px;
  background: #fff;
  border-radius: 10px;
  font-size: 13px;
  color: var(--gray-3);
  line-height: 1.8;
}

/* ============================
   导航栏
   ============================ */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--gray-2);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-title {
  font-size: 17px;
  font-weight: 600;
}
.nav-action {
  font-size: 14px;
  color: var(--red);
  cursor: pointer;
  padding: 4px 8px;
}

/* ============================
   排队进度页
   ============================ */
.queue-content {
  padding: 16px;
  padding-bottom: 40px;
}

.my-number-card {
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  color: #fff;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  box-shadow: 0 4px 20px rgba(7,193,96,0.25);
}
.my-number-card.hall-5-theme {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  box-shadow: 0 4px 20px rgba(87,107,149,0.25);
}
.my-number-card.hall-6-theme {
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  box-shadow: 0 4px 20px rgba(139,92,246,0.25);
}

.my-number-label {
  font-size: 14px;
  opacity: 0.85;
  margin-bottom: 8px;
}
.my-number {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 2px;
}
.my-number-name {
  font-size: 14px;
  opacity: 0.85;
  margin-top: 8px;
}

/* 状态信息 */
.status-info {
  background: #fff;
  border-radius: 12px;
  padding: 4px 16px;
  margin-bottom: 16px;
}
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-1);
}
.status-row:last-child { border-bottom: none; }
.status-label {
  font-size: 14px;
  color: var(--gray-3);
}
.status-value {
  font-size: 16px;
  font-weight: 600;
}
.status-value.highlight {
  color: var(--green);
}

/* 进度条 */
.progress-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.progress-bar {
  height: 8px;
  background: var(--gray-1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), #4cd964);
  border-radius: 4px;
  transition: width 0.5s ease;
}
.progress-bar-fill.hall-5-theme {
  background: linear-gradient(90deg, var(--blue), #7989b5);
}
.progress-bar-fill.hall-6-theme {
  background: linear-gradient(90deg, var(--purple), #a78bfa);
}
.progress-text {
  font-size: 13px;
  color: var(--gray-3);
  text-align: center;
}

/* 排队列表 */
.queue-list-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
}
.section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--gray-1);
  border-radius: 8px;
  font-size: 14px;
}
.queue-item.is-me {
  font-weight: 600;
  background: var(--green-light);
}
.queue-item.is-me.hall-5-theme {
  background: var(--blue-light);
}
.queue-item.is-me.hall-6-theme {
  background: var(--purple-light);
}
.queue-item.is-calling {
  background: #fff3e0;
  border: 1px solid var(--orange);
}
.qi-number {
  font-weight: 500;
}
.qi-status {
  font-size: 12px;
  color: var(--gray-3);
}
.empty-list {
  text-align: center;
  padding: 20px;
  color: var(--gray-3);
  font-size: 14px;
}

/* ============================
   叫号提醒（全屏）
   ============================ */
.call-alert {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
.call-alert.show {
  display: flex;
  animation: alertBgFlash 0.8s ease-in-out infinite;
}
@keyframes alertBgFlash {
  0%, 100% { background: rgba(0,0,0,0.75); }
  50% { background: rgba(239,68,68,0.9); }
}
.call-alert-content {
  background: #fff;
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  animation: alertBounce 0.5s ease;
}
@keyframes alertBounce {
  0% { transform: scale(0.7); opacity: 0; }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
.call-alert-icon {
  font-size: 64px;
  margin-bottom: 16px;
}
.call-alert-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 12px;
}
.call-alert-hall {
  font-size: 18px;
  color: var(--gray-4);
  margin-bottom: 8px;
}
.call-alert-number {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-4);
  margin-bottom: 8px;
  letter-spacing: 2px;
}
.call-alert-hint {
  font-size: 13px;
  color: var(--orange);
  margin-bottom: 20px;
}
.call-alert.alarm-active .call-alert-content {
  animation: alertBounce 0.5s ease, alertShake 0.4s ease 0.5s infinite;
}
@keyframes alertShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.call-alert.alarm-active .call-alert-icon {
  animation: iconPulse 0.5s ease-in-out infinite;
}
@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

/* ============================
   管理端
   ============================ */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid var(--gray-2);
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-title {
  font-size: 18px;
  font-weight: 600;
}
.admin-actions {
  display: flex;
  gap: 8px;
}

.admin-body {
  padding: 16px;
  padding-bottom: 40px;
}

.admin-section {
  margin-bottom: 24px;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}
.section-sub {
  font-size: 12px;
  color: var(--gray-3);
}

/* 厅面板 */
.hall-panel {
  background: #fff;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
  border-left: 4px solid var(--green);
}
.hall-panel.hall-5-border { border-left-color: var(--blue); }
.hall-panel.hall-6-border { border-left-color: var(--purple); }

.hall-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.hall-panel-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
}
.hall-panel-name.hall-5-text { color: var(--blue); }
.hall-panel-name.hall-6-text { color: var(--purple); }

.hall-panel-stats {
  display: flex;
  gap: 6px;
}
.stat-badge {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 500;
}
.stat-waiting { background: #fff3e0; color: var(--orange); }
.stat-calling { background: #e8f7ee; color: var(--green); }
.stat-done { background: var(--gray-1); color: var(--gray-3); }

.hall-current {
  font-size: 14px;
  color: var(--gray-3);
  margin-bottom: 12px;
}
.hall-current strong {
  color: var(--gray-4);
  font-size: 16px;
}

/* 呼叫按钮 */
.btn-call-next {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--green);
  cursor: pointer;
  margin-bottom: 12px;
  transition: opacity 0.2s;
}
.btn-call-next:active { opacity: 0.85; }
.btn-call-next:disabled { opacity: 0.5; }
.btn-call-next.hall-5-bg { background: var(--blue); }
.btn-call-next.hall-6-bg { background: var(--purple); }

/* 主题色类 */
.hall-4-bg { background: var(--green); }
.hall-5-bg { background: var(--blue); }
.hall-6-bg { background: var(--purple); }

/* 排队条目 */
.admin-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 500px;
  overflow-y: auto;
}
.entry-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--gray-1);
  border-radius: 8px;
}
.entry-item.entry-calling {
  background: #e8f7ee;
  border: 1px solid var(--green);
}
.entry-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-wrap: wrap;
}
.entry-number {
  font-weight: 600;
  font-size: 15px;
}
.entry-name {
  font-size: 14px;
  color: var(--gray-4);
}
.entry-phone {
  font-size: 12px;
  color: var(--gray-3);
}
.entry-phone-link {
  font-size: 13px;
  color: var(--blue);
  text-decoration: none;
  cursor: pointer;
  font-weight: 500;
}
.entry-phone-link:active {
  opacity: 0.7;
}
.entry-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}
.status-waiting { background: #fff3e0; color: var(--orange); }
.status-calling { background: var(--green); color: #fff; }
.status-done { background: var(--gray-2); color: var(--gray-3); }
.status-skipped { background: #fee2e2; color: var(--red); }

.entry-actions {
  display: flex;
  gap: 4px;
}

/* ============================
   设置卡片
   ============================ */
.settings-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.settings-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.settings-desc {
  font-size: 13px;
  color: var(--gray-3);
  margin-bottom: 12px;
  line-height: 1.5;
}

/* 厅开关 */
.hall-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hall-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--gray-1);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.hall-toggle.active {
  background: #f0f7ff;
}
.hall-toggle-name {
  font-size: 15px;
  font-weight: 500;
}
.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--gray-2);
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on {
  background: var(--green);
}
.toggle-switch.on::after {
  transform: translateX(20px);
}

/* 二维码 */
.qr-url {
  font-size: 13px;
  color: var(--gray-3);
  word-break: break-all;
  background: var(--gray-1);
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 12px;
}
.qr-display {
  text-align: center;
  margin-bottom: 12px;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.qr-display img {
  width: 220px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  display: block;
}
.qr-placeholder {
  color: var(--gray-3);
  font-size: 14px;
}
.qr-tip {
  font-size: 13px;
  color: var(--gray-3);
  margin-top: 8px;
}

/* ============================
   弹窗
   ============================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.show {
  display: flex;
}
.modal {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  max-width: 360px;
  width: 100%;
}
.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  text-align: center;
}
.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}
.modal-actions button {
  flex: 1;
}
.modal .form-group input {
  border-color: var(--gray-2);
}

/* ============================
   Toast
   ============================ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  max-width: 90%;
  text-align: center;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================
   延后申请
   ============================ */
.postpone-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.postpone-info {
  flex: 1;
}
.postpone-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-4);
}
.postpone-count-text,
.postpone-count {
  display: block;
  font-size: 12px;
  color: var(--gray-3);
  margin-top: 4px;
}
.btn-postpone {
  background: #fff;
  color: var(--orange);
  border: 1.5px solid var(--orange);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}
.btn-postpone:active { opacity: 0.7; }

/* 延后选择弹窗 */
.postpone-options {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.postpone-option {
  flex: 1;
  padding: 14px 8px;
  border: 1.5px solid var(--orange);
  background: #fff;
  color: var(--orange);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.postpone-option:active {
  background: var(--orange);
  color: #fff;
}

/* ============================
   管理端 - 条目标签
   ============================ */
.entry-tag {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.tag-postpone {
  background: #fff3e0;
  color: var(--orange);
}
.tag-noshow {
  background: #fee2e2;
  color: var(--red);
}

/* ============================
   响应式
   ============================ */
@media (min-width: 768px) {
  .admin-body {
    max-width: 768px;
    margin: 0 auto;
  }
}
