/* 浅色模式主题与基础样式 */
:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --border: #cbd5e1;
  --border-focus: #3b82f6;
  --danger: #dc2626;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding: 1.5rem 1rem 3rem;
}

.main-container {
  max-width: 640px;
  margin: 0 auto;
}

.admin-container {
  max-width: 900px;
}

/* 标题区 */
.page-header {
  margin-bottom: 1.25rem;
  text-align: center;
}

.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  text-align: left;
}

.admin-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 顶部待抽班级区 */
.pool-box {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.pool-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.pool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 500px) {
  .pool-grid {
    grid-template-columns: 1fr;
  }
}

.pool-col-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.pool-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pool-badge {
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 4px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-weight: 500;
}

.pool-badge.is-drawn {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
  text-decoration: line-through;
}

/* 通用卡片容器 */
.step-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.user-info-text {
  font-size: 0.85rem;
  font-weight: normal;
  color: var(--text-muted);
}

.section-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* 表单与输入框 */
.form-item {
  margin-bottom: 1rem;
}

.form-item label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}

.input-text,
input[type="text"],
input[type="tel"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.15s ease;
}

input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* 按钮规范 */
.btn-main {
  width: 100%;
  padding: 11px;
  border-radius: 6px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.btn-main:hover {
  background: var(--primary-hover);
}

.btn-sub {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #334155;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sub:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-danger {
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #dc2626;
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-danger:hover {
  background: #fee2e2;
}

.link-btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #334155;
  font-size: 0.85rem;
  text-decoration: none;
}

.link-btn:hover {
  background: #f8fafc;
}

/* 6个编号卡片网格 */
.numbers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 1.25rem;
}

@media (max-width: 480px) {
  .numbers-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.number-btn {
  padding: 1.5rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all 0.15s ease;
}

.number-btn:not(:disabled):hover {
  border-color: var(--primary);
  background: #f0f7ff;
  color: var(--primary);
  transform: translateY(-1px);
}

.number-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.25);
}

.number-btn.disabled,
.number-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
  box-shadow: none;
  font-size: 0.85rem;
}

/* 抽中结果展示区（紧随卡片下方） */
.result-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  text-align: center;
}

.result-label {
  font-size: 0.8rem;
  color: #2563eb;
  font-weight: 600;
}

.result-class {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1e3a8a;
  margin-top: 4px;
}

/* 抽签后直接展示的签名区 */
.draw-sign-section {
  border-top: 1px solid var(--surface-border);
  padding-top: 1.25rem;
}

.sign-hint {
  font-size: 0.88rem;
  color: #475569;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.canvas-wrap {
  border: 1px solid #94a3b8;
  background: #ffffff;
  border-radius: 6px;
  margin-bottom: 1rem;
  touch-action: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

#signature-canvas {
  width: 100%;
  height: 180px;
  display: block;
  cursor: crosshair;
}

.canvas-actions {
  display: flex;
  gap: 10px;
}

.canvas-actions .btn-sub {
  width: 90px;
}

/* 抽签完成状态 */
.done-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #166534;
  margin-bottom: 1rem;
  text-align: center;
}

.done-details {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 1rem 1.25rem;
}

.done-details p {
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: #334155;
}

.done-details span {
  font-weight: 700;
  color: #0f172a;
}

.done-sig-wrap {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.done-sig-wrap img {
  max-height: 70px;
  background: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  margin-top: 6px;
}

/* 后台管理编辑列表 */
.pool-edit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 1rem;
}

.pool-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.row-num {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  width: 20px;
}

.row-fields {
  display: flex;
  flex: 1;
  gap: 8px;
}

.row-status {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
}

.row-status.is-drawn {
  color: #d97706;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
}

.card-footer .btn-main {
  width: auto;
  padding: 8px 20px;
}

/* 记录表格 */
.table-wrap {
  overflow-x: auto;
}

.simple-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.simple-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  color: #475569;
  font-weight: 600;
  white-space: nowrap;
}

.simple-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

.simple-table tr:hover td {
  background: #f8fafc;
}

.sig-thumb {
  height: 28px;
  background: #ffffff;
  border-radius: 2px;
  border: 1px solid #cbd5e1;
  padding: 2px 4px;
  cursor: pointer;
}

/* 弹层与 Toast */
.modal-layer {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.modal-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-md);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  font-weight: 700;
  color: var(--text);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  border: 1px solid #334155;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 全屏横屏手写签名遮罩 */
.landscape-modal {
  position: fixed;
  background: #ffffff;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 768px) and (orientation: portrait) {
  .landscape-modal {
    transform: rotate(90deg);
    transform-origin: top left;
    position: fixed;
    top: 0;
    left: 100vw;
    width: 100vh;
    height: 100vw;
  }
}

@media (orientation: landscape), (min-width: 769px) {
  .landscape-modal {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
  }
}

.landscape-header {
  height: 52px;
  padding: 8px 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.landscape-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.landscape-actions {
  display: flex;
  gap: 8px;
}

.landscape-actions .btn-main {
  width: auto;
  padding: 6px 16px;
  font-size: 0.85rem;
}

.landscape-canvas-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  height: calc(100% - 52px);
  background: #ffffff;
}

#landscape-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}
