* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; background: #f4f6fb; color: #1f2937; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.card {
  background: #fff; border-radius: 14px; padding: 32px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08); width: 360px;
}
.card h1 { margin: 0 0 24px; font-size: 20px; text-align: center; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #4b5563; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; outline: none; transition: border .15s; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: #2563eb; }
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-row input { flex: 1; }
.captcha-row .cap-img {
  width: 120px; background: #f4f6fb; border-radius: 8px; border: 1px solid #d1d5db;
  display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden;
}
.captcha-row .cap-img svg { max-width: 100%; height: 40px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 10px 16px; background: #2563eb; color: #fff; font-weight: 600;
  border: none; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.btn:hover { background: #1d4ed8; }
.btn:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: #16a34a; }
.btn-success:hover { background: #15803d; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: #2563eb; border: 1px solid #2563eb; }
.btn-ghost:hover { background: #eff6ff; }

.alert { font-size: 13px; padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; }
.alert-err { background: #fee2e2; color: #991b1b; }
.alert-ok { background: #dcfce7; color: #166534; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ---------- App layout ---------- */
.app {
  min-height: 100vh; display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "side top" "side main";
}
.sidebar { grid-area: side; background: #1f2937; color: #e5e7eb; padding: 16px 0; }
.sidebar h2 { margin: 0 18px 16px; font-size: 16px; color: #fff; }
.sidebar .nav-item {
  display: flex; align-items: center; gap: 8px; padding: 11px 18px;
  cursor: pointer; color: #cbd5e1; border-left: 3px solid transparent; font-size: 14px;
}
.sidebar .nav-item:hover { background: #111827; color: #fff; }
.sidebar .nav-item.active { background: #111827; color: #fff; border-left-color: #3b82f6; }
.sidebar .nav-item .ico { font-size: 16px; }

.topbar {
  grid-area: top; background: #fff; padding: 0 22px;
  border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .right { display: flex; gap: 8px; align-items: center; }
.topbar .user { color: #6b7280; margin-right: 8px; font-size: 13px; }

.main { grid-area: main; padding: 22px; overflow: auto; }

.view { display: none; }
.view.active { display: block; }

.section { background: #fff; border-radius: 10px; padding: 18px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.section h3 { margin: 0 0 14px; font-size: 15px; }
.section .section-actions { float: right; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 200px; }

textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; resize: vertical; font-family: inherit; outline: none;
}
textarea:focus { border-color: #2563eb; }

/* ---------- Gift grid ---------- */
.gift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.gift-card {
  border: 2px solid #e5e7eb; border-radius: 10px; padding: 12px 8px;
  text-align: center; cursor: pointer; transition: all .15s; background: #fff;
}
.gift-card:hover { border-color: #93c5fd; }
.gift-card.selected { border-color: #2563eb; background: #eff6ff; }
.gift-card.disabled { opacity: .5; pointer-events: none; }
.gift-emoji { font-size: 36px; line-height: 1; }
.gift-stars { color: #f59e0b; font-weight: 600; font-size: 13px; margin-top: 6px; }
.gift-id { color: #9ca3af; font-size: 10px; word-break: break-all; margin-top: 2px; }
.char-count { text-align: right; color: #9ca3af; font-size: 12px; margin-top: 4px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid #f1f5f9; text-align: center; vertical-align: middle; }
th { background: #f9fafb; color: #374151; font-weight: 600; font-size: 12px; }
.status-sent { color: #15803d; font-weight: 600; }
.status-failed { color: #b91c1c; font-weight: 600; }
.status-running { color: #2563eb; font-weight: 600; }
.muted { color: #9ca3af; }

/* ---------- Modal ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); display: none;
  align-items: center; justify-content: center; z-index: 50;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 12px; min-width: 360px; max-width: 720px; padding: 24px;
  box-shadow: 0 20px 40px rgba(0,0,0,.2); max-height: 88vh; overflow: auto;
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal .actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }

.tag { display: inline-block; background: #eff6ff; color: #1e40af; padding: 1px 8px; border-radius: 999px; font-size: 11px; }
.tag-green { background: #dcfce7; color: #166534; }
.tag-red { background: #fee2e2; color: #991b1b; }
.tag-gray { background: #f3f4f6; color: #4b5563; }

.empty { padding: 32px; text-align: center; color: #9ca3af; }

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