/* ==========================================================================
   渡舟 · 批量授权工作台
   ========================================================================== */

.modal-wide {
  width: min(1120px, calc(100vw - 40px));
}

.batch-surface {
  height: min(782px, calc(100vh - 40px));
}

.batch-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  flex: 1 1 auto;
  min-height: 0;
}

.batch-input-pane,
.batch-run-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 21px 26px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.batch-input-pane {
  border-right: 1px solid var(--line);
  background:
    radial-gradient(520px 260px at 0% 0%, rgba(232, 234, 251, 0.28), rgba(232, 234, 251, 0) 66%),
    rgba(250, 247, 240, 0.28);
}

.batch-run-pane {
  background: rgba(255, 254, 251, 0.36);
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  margin-bottom: 7px;
}

.pane-head h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.pane-hint {
  flex: 0 0 auto;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

.pane-hint code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 254, 251, 0.76);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 10px;
  white-space: nowrap;
}

.pill.is-over {
  border-color: rgba(189, 69, 48, 0.24);
  background: var(--red-soft);
  color: var(--red);
}

.batch-auto-alert {
  flex: 0 0 auto;
  margin-bottom: 10px;
  padding: 9px 12px;
  border: 1px solid rgba(169, 117, 32, 0.24);
  border-radius: 10px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 11px;
  line-height: 1.6;
}

.batch-textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 244px;
  padding: 12px 13px;
  border-radius: 13px;
  background:
    linear-gradient(rgba(255, 254, 251, 0.96), rgba(255, 254, 251, 0.96)),
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(230, 225, 214, 0.5) 22px 23px);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 23px;
  resize: none;
  tab-size: 2;
}

.batch-textarea::placeholder {
  color: var(--muted-light);
  line-height: 23px;
}

.batch-validation {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 0 0 auto;
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(189, 69, 48, 0.2);
  border-radius: 10px;
  background: rgba(251, 231, 226, 0.58);
  color: var(--red);
  font-size: 10.5px;
  line-height: 1.6;
}

.validation-icon {
  margin-top: 1px;
}

.batch-validation ul {
  margin: 0;
  padding: 0 0 0 1px;
  list-style: none;
}

.batch-validation li + li {
  margin-top: 2px;
}

.batch-validation li.is-more {
  color: var(--muted);
}

#batch-start {
  flex: 0 0 auto;
  min-height: 45px;
  margin-top: 12px;
}

.pane-foot {
  flex: 0 0 auto;
  margin: 9px 2px 0;
  color: var(--muted-light);
  font-size: 10px;
  line-height: 1.6;
  text-align: center;
}

/* --------------------------------------------------------------------------
   进度区
   -------------------------------------------------------------------------- */

.run-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card-soft);
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.run-state::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.run-state.is-running {
  border-color: rgba(40, 62, 203, 0.16);
  background: var(--indigo-tint);
  color: var(--indigo);
}

.run-state.is-running::before {
  animation: runDot 1.4s ease-in-out infinite;
}

.run-state.is-complete {
  border-color: rgba(47, 143, 104, 0.2);
  background: var(--green-soft);
  color: var(--green);
}

.run-state.is-cancelled {
  border-color: rgba(189, 69, 48, 0.2);
  background: var(--red-soft);
  color: var(--red);
}

@keyframes runDot {
  0%, 100% { opacity: 0.35; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.progress-shell {
  flex: 0 0 auto;
  padding: 13px 15px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(250, 247, 240, 0.55);
}

.progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
}

#batch-progress-percent {
  color: var(--indigo);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 650;
}

.progress-track {
  position: relative;
  height: 7px;
  border-radius: 999px;
  background: rgba(216, 209, 194, 0.5);
  overflow: hidden;
}

.progress-bar {
  position: relative;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(90deg, #354ad2, var(--indigo) 58%, #5b6ce0);
  box-shadow: 0 0 12px rgba(40, 62, 203, 0.36);
  transition: width 0.5s var(--ease);
  overflow: hidden;
}

.progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.34), transparent);
  transform: translateX(-100%);
  animation: progressShine 2.2s ease-in-out infinite;
}

.batch-surface .progress-bar.is-complete {
  background: linear-gradient(90deg, #2f8f68, #3ba77b);
  box-shadow: 0 0 12px rgba(47, 143, 104, 0.32);
}

@keyframes progressShine {
  0% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}

.batch-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex: 0 0 auto;
  margin: 11px 0;
}

.batch-stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 254, 251, 0.72);
}

.batch-stat strong {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

.batch-stat span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.batch-stat.is-running strong {
  color: var(--indigo);
}

.batch-stat.is-success strong {
  color: var(--green);
}

.batch-stat.is-failed strong {
  color: var(--red);
}

.batch-table-wrap {
  flex: 1 1 auto;
  min-height: 160px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 254, 251, 0.62);
  overflow: auto;
  overscroll-behavior: contain;
}

.batch-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.batch-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: #f8f5ed;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: left;
  white-space: nowrap;
}

.batch-table th:nth-child(1) {
  width: 38%;
}

.batch-table th:nth-child(2) {
  width: 24%;
}

.batch-table th:nth-child(3) {
  width: 38%;
}

.batch-table td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(230, 225, 214, 0.6);
  color: var(--ink-soft);
  font-size: 11px;
  vertical-align: middle;
}

.batch-table tbody tr:last-child td {
  border-bottom: 0;
}

.batch-table tbody tr:hover {
  background: rgba(247, 243, 233, 0.56);
}

.batch-email {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 11.5px;
}

.batch-result-cell {
  min-width: 0;
}

.token-preview {
  display: inline-block;
  max-width: 100%;
  padding: 2px 6px;
  border: 1px solid rgba(40, 62, 203, 0.1);
  border-radius: 6px;
  background: var(--indigo-tint);
  color: var(--indigo-deep);
  font-family: var(--mono);
  font-size: 9.5px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.batch-error {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--red);
  font-size: 10px;
}

.batch-muted {
  color: var(--muted-light);
  font-size: 10px;
}

.batch-table .empty-row td {
  padding: 40px 16px;
  color: var(--muted-light);
  font-size: 11px;
  text-align: center;
}

.batch-table .badge {
  font-size: 9px;
}

.batch-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  flex: 0 0 auto;
  margin-top: 12px;
}

.batch-actions .btn-text {
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   响应式
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  .batch-surface {
    height: calc(100vh - 20px);
  }

  .batch-layout {
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto;
  }

  .batch-input-pane,
  .batch-run-pane {
    padding: 18px 18px 20px;
    overflow: visible;
  }

  .batch-input-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .batch-textarea {
    flex: 0 0 auto;
    min-height: 184px;
  }

  .batch-table-wrap {
    flex: 0 0 auto;
    min-height: 220px;
    max-height: 320px;
  }
}

@media (max-width: 680px) {
  .batch-surface {
    border-radius: 22px;
  }

  .batch-layout {
    min-height: 0;
  }

  .batch-input-pane,
  .batch-run-pane {
    padding: 15px 14px 18px;
  }

  .batch-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .batch-actions {
    flex-wrap: wrap;
  }

  .batch-actions .btn {
    flex: 1 1 auto;
  }

  .batch-actions .btn-text {
    margin-left: 0;
  }

  .batch-table th:nth-child(1) {
    width: 42%;
  }

  .batch-table th:nth-child(2) {
    width: 25%;
  }

  .batch-table th:nth-child(3) {
    width: 33%;
  }
}
