* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  background: #f5f7fb;
  color: #222;
}

.page {
  padding: 16px;
}

.card {
  max-width: 760px;
  margin: 0 auto;
  background: #fff;
  border-radius: 16px;
  padding: 18px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.sub {
  margin: 0 0 16px;
  color: #666;
  font-size: 14px;
}

.entry-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.entry-btn,
.primary-btn,
.secondary-btn,
.cancel-btn,
.slot-btn,
.duration-btn {
  border: 0;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
  cursor: pointer;
}

button:disabled,
.entry-btn:disabled,
.primary-btn:disabled,
.secondary-btn:disabled,
.cancel-btn:disabled,
.slot-btn:disabled,
.duration-btn:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.is-loading {
  position: relative;
}

.is-loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: btn-spin 0.75s linear infinite;
}

@keyframes btn-spin {
  to {
    transform: rotate(360deg);
  }
}

.entry-btn-book,
.blue-btn {
  background: #2563eb;
  color: #fff;
}

.entry-btn-cancel,
.red-btn,
.cancel-btn {
  background: #dc2626;
  color: #fff;
}

.secondary-btn {
  background: #e5e7eb;
  color: #111827;
}

.pane {
  display: none;
}

.pane.active {
  display: block;
}

.hidden {
  display: none !important;
}

.section {
  margin-top: 18px;
}

.label {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.hint {
  color: #666;
  font-size: 13px;
  margin-bottom: 10px;
  line-height: 1.5;
}

.day-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
}

.day-section:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.day-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #111827;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.slot-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
  padding: 10px 6px;
}

.slot-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.slot-btn.disabled {
  background: #f3f4f6;
  color: #9ca3af;
  border-color: #e5e7eb;
  cursor: not-allowed;
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.duration-btn {
  border: 1px solid #d1d5db;
  background: #fff;
  color: #111827;
}

.duration-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.duration-btn.disabled {
  background: #f3f4f6;
  color: #9ca3af;
  border-color: #e5e7eb;
  cursor: not-allowed;
}

.text-input {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 12px;
  font-size: 16px;
}

.saved-code-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 14px 14px 16px;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: linear-gradient(180deg, #f8fbff 0%, #edf4ff 100%);
}

.saved-code-caption {
  color: #52637a;
  font-size: 13px;
  font-weight: 700;
}

.saved-code-value {
  margin-top: 4px;
  color: #0f172a;
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.saved-code-clear {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.saved-code-clear:active {
  transform: translateY(1px);
}

.preview {
  padding: 12px;
  border-radius: 12px;
  background: #f3f4f6;
  color: #374151;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.single-action-row {
  grid-template-columns: 1fr;
}

.message {
  margin-top: 10px;
  font-size: 14px;
  color: #b42318;
  line-height: 1.5;
  white-space: pre-wrap;
}

.message.ok {
  color: #027a48;
}

.booking-list {
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.cancel-booking-item {
  width: 100%;
  max-width: 100%;
  position: relative;
  box-sizing: border-box;
  border: 1px solid #ead1d1;
  background: #f6d3d3;
  border-radius: 0;
  padding: 14px 16px 16px;
  overflow: hidden;
}

.cancel-booking-time {
  font-size: 16px;
  line-height: 1.5;
  font-weight: 700;
  color: #222;
  margin-bottom: 12px;
  word-break: break-word;
}

.cancel-booking-item .cancel-btn {
  width: 100%;
  box-sizing: border-box;
}

.cancel-booking-item .cancel-btn.confirming {
  background-color: #dc2626;
  background-image: linear-gradient(#991b1b, #991b1b);
  background-position: left center;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  animation: cancel-confirm-countdown 4s linear forwards;
}

@keyframes cancel-confirm-countdown {
  to {
    background-size: 0% 100%;
  }
}

.booking-item {
  width: 100%;
  max-width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}

.booking-time {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 0;
  line-height: 1.5;
  word-break: break-word;
}

.booking-item .cancel-btn {
  width: 100%;
  align-self: stretch;
}

.booking-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  width: 100%;
  max-width: 100%;
}

.success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.success-card {
  width: calc(100% - 40px);
  max-width: 320px;
  background: #fff;
  border-radius: 16px;
  padding: 22px 18px;
  text-align: center;
}

.success-title {
  font-size: 20px;
  font-weight: 700;
  color: #027a48;
  margin-bottom: 8px;
}

.success-text {
  color: #666;
  font-size: 14px;
}

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

  .slot-btn {
    padding: 10px 4px;
    font-size: 14px;
  }
  
  .cancel-booking-item {
    padding: 12px 12px 14px;
  }

  .cancel-booking-time {
    font-size: 15px;
    margin-bottom: 10px;
  }
}
