.batch-page {
  --batch-blue: #1a73e8;
  --batch-border: #dadce0;
  --batch-bg: #f8f9fa;
  --batch-text: #202124;
  --batch-muted: #5f6368;
  --batch-error: #d93025;
  --batch-success: #1e8e3e;
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--batch-text);
  background: var(--batch-bg);
}

.batch-window {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}

.batch-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.batch-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 500;
}

.batch-topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.95rem;
}

.batch-user-name {
  color: var(--batch-muted);
}

.batch-back-link {
  color: var(--batch-blue);
  text-decoration: none;
}

.batch-back-link:hover {
  text-decoration: underline;
}

.batch-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.batch-card {
  background: #fff;
  border: 1px solid var(--batch-border);
  border-radius: 8px;
  padding: 24px;
}

.batch-card h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 500;
}

.batch-lead {
  margin: 0 0 12px;
  color: var(--batch-muted);
  line-height: 1.5;
}

.batch-lead-muted {
  margin: 0 0 20px;
  font-size: 0.92rem;
}

.batch-lead-muted {
  margin-top: -12px;
  font-size: 0.92rem;
}

.batch-lead code {
  font-size: 0.9em;
  background: #f1f3f4;
  padding: 1px 5px;
  border-radius: 4px;
}

.batch-upload-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.batch-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 180px;
  padding: 28px 20px;
  border: 2px dashed var(--batch-border);
  border-radius: 8px;
  background: #fafbfc;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.batch-dropzone:hover,
.batch-dropzone:focus-visible {
  border-color: var(--batch-blue);
  background: #f3f8ff;
  outline: none;
}

.batch-dropzone--dragover {
  border-color: var(--batch-blue);
  background: #e8f0fe;
}

.batch-dropzone--invalid {
  border-color: var(--batch-error);
  background: #fef7f6;
}

.batch-dropzone--ready {
  border-color: var(--batch-success);
  background: #f2fbf5;
}

.batch-dropzone-icon {
  color: var(--batch-blue);
}

.batch-dropzone-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.batch-dropzone-hint {
  margin: 0;
  color: var(--batch-muted);
  font-size: 0.92rem;
}

.batch-browse-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--batch-blue);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.batch-dropzone-file {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: var(--batch-text);
  font-weight: 500;
}

.batch-review {
  padding: 16px;
  border: 1px solid var(--batch-border);
  border-radius: 8px;
  background: #fafbfc;
}

.batch-review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.batch-review-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.batch-review-status {
  font-size: 0.85rem;
  font-weight: 500;
}

.batch-review-status--ok {
  color: var(--batch-success);
}

.batch-review-status--error {
  color: var(--batch-error);
}

.batch-review-summary {
  margin: 0 0 12px;
  color: var(--batch-text);
}

.batch-review-warnings {
  margin: 0 0 12px;
  padding-left: 20px;
  color: #b06000;
}

.batch-review-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 16px;
  margin: 0 0 16px;
}

.batch-review-columns dt {
  margin: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--batch-muted);
}

.batch-review-columns dd {
  margin: 0;
  font-size: 0.92rem;
}

.batch-preview-wrap {
  margin-bottom: 12px;
}

.batch-preview-title {
  margin: 0 0 8px;
  font-size: 0.92rem;
  font-weight: 500;
}

.batch-preview-table-wrap {
  overflow: auto;
  border: 1px solid var(--batch-border);
  border-radius: 4px;
  background: #fff;
}

.batch-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.batch-preview-table th,
.batch-preview-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef0f2;
  text-align: left;
  white-space: nowrap;
}

.batch-preview-table th {
  background: #f8f9fa;
  font-weight: 500;
  color: var(--batch-muted);
}

.batch-review-issues {
  margin: 0;
  padding-left: 20px;
  color: var(--batch-error);
  font-size: 0.88rem;
}

.batch-file-input {
  display: none;
}

.batch-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.batch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 4px;
  border: 1px solid transparent;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
}

.batch-btn-primary {
  background: var(--batch-blue);
  color: #fff;
}

.batch-btn-primary:hover {
  background: #1765cc;
}

.batch-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.batch-btn-secondary {
  background: #fff;
  color: var(--batch-blue);
  border-color: var(--batch-border);
}

.batch-status {
  color: var(--batch-muted);
}

.batch-status-error {
  color: var(--batch-error);
}

.batch-search-options {
  margin: 20px 0 0;
  padding: 16px;
  border: 1px solid #d8e0ea;
  border-radius: 10px;
  background: #fafbfd;
}

.batch-search-options-title {
  padding: 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
}

.batch-search-options-lead {
  margin: 0 0 12px;
  color: var(--batch-muted);
  font-size: 0.9rem;
}

.batch-search-options-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
  padding: 12px 16px;
  border: 1px solid #dbe3ed;
  border-radius: 8px;
  background: #fff;
}

.batch-search-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
}

.batch-search-option input {
  margin: 0;
}

.batch-search-option-label {
  font-weight: 600;
  white-space: nowrap;
}

.batch-time-estimate {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef4ff;
  border: 1px solid #c9d8f2;
  font-size: 0.88rem;
  line-height: 1.45;
}

.batch-search-options-error {
  margin: 10px 0 0;
  color: #b42318;
  font-size: 0.88rem;
}

.batch-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.batch-progress-status {
  font-size: 0.9rem;
  color: var(--batch-muted);
  text-transform: capitalize;
}

.batch-progress-bar-wrap {
  height: 8px;
  background: #e8eaed;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 12px;
}

.batch-progress-bar {
  height: 100%;
  background: var(--batch-blue);
  transition: width 0.25s ease;
}

.batch-progress-counts {
  margin: 0 0 4px;
  font-weight: 500;
}

.batch-progress-message {
  margin: 0 0 8px;
  color: var(--batch-muted);
}

.batch-timing-summary {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4f7fb;
  border: 1px solid #d8e0ea;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.82rem;
  color: #1f2937;
  line-height: 1.45;
}

.batch-progress-note {
  margin: 0 0 16px;
  color: var(--batch-muted);
  font-size: 0.88rem;
}

.batch-log-wrap {
  margin-bottom: 16px;
}

.batch-log-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 500;
}

.batch-log {
  margin: 0;
  padding: 12px;
  max-height: 220px;
  overflow: auto;
  background: #f8f9fa;
  border: 1px solid var(--batch-border);
  border-radius: 4px;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.batch-btn-small {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.batch-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.batch-history-header h2 {
  margin: 0;
}

.batch-history-empty {
  margin: 8px 0 0;
  color: var(--batch-muted);
  font-size: 0.9rem;
}

.batch-history-table-wrap {
  overflow: auto;
  border: 1px solid var(--batch-border);
  border-radius: 4px;
  background: #fff;
}

.batch-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.batch-history-table th,
.batch-history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef0f2;
  text-align: left;
  white-space: nowrap;
}

.batch-history-table th {
  background: #f8f9fa;
  font-weight: 500;
  color: var(--batch-muted);
}

.batch-history-table tr:last-child td {
  border-bottom: none;
}

.batch-history-file {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.batch-history-status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  background: #eef0f2;
  color: var(--batch-muted);
}

.batch-history-status--completed {
  background: #e6f4ea;
  color: var(--batch-success);
}

.batch-history-status--running,
.batch-history-status--queued {
  background: #e8f0fe;
  color: var(--batch-blue);
}

.batch-history-status--failed,
.batch-history-status--interrupted {
  background: #fce8e6;
  color: var(--batch-error);
}

.batch-history-actions {
  display: flex;
  gap: 12px;
}

.batch-link-btn {
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: var(--batch-blue);
  cursor: pointer;
}

.batch-link-btn:hover {
  text-decoration: underline;
}

.batch-link-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.batch-link-btn--danger {
  color: var(--batch-error);
}

.batch-notify-overlay[hidden] {
  display: none !important;
}

.batch-notify-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.batch-notify-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.batch-notify-modal {
  display: flex;
  flex-direction: column;
  width: min(480px, 100%);
  max-height: min(80vh, 720px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(31, 45, 61, 0.25);
  overflow: hidden;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.2s ease;
}

.batch-notify-overlay.is-active .batch-notify-modal {
  transform: scale(1) translateY(0);
}

.batch-notify-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--batch-border);
}

.batch-notify-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
}

.batch-notify-subtitle {
  margin: 6px 0 0;
  color: var(--batch-muted);
  font-size: 0.88rem;
}

.batch-notify-close {
  border: 0;
  background: transparent;
  color: #777;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.batch-notify-transcript {
  flex: 1 1 auto;
  min-height: 280px;
  max-height: calc(80vh - 110px);
  overflow: auto;
  padding: 16px 18px 20px;
}

.batch-notify-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 12px;
  color: #555;
}

.batch-notify-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--batch-border);
  border-radius: 8px;
  font: inherit;
  box-sizing: border-box;
}

body.batch-notify-open {
  overflow: hidden;
}

.batch-notify-transcript .cf-chat-message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.batch-notify-transcript .cf-chat-message-user {
  justify-content: flex-end;
}

.batch-notify-transcript .cf-chat-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--batch-blue) 0%, #7aa6f1 100%);
  flex: 0 0 auto;
}

.batch-notify-transcript .cf-chat-avatar-step {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.batch-notify-transcript .cf-chat-bubble {
  max-width: calc(100% - 48px);
  padding: 12px 14px;
  border-radius: 12px;
  border-top-left-radius: 4px;
  background: #f3f6fb;
  color: #333;
  font-size: 14px;
  line-height: 1.45;
}

.batch-notify-transcript .cf-chat-bubble.user-response {
  border-radius: 12px;
  border-top-right-radius: 4px;
  background: var(--batch-blue);
  color: #fff;
}

.batch-notify-transcript .cf-chat-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.batch-notify-transcript .cf-chat-option-btn,
.batch-notify-transcript .cf-chat-submit-btn {
  cursor: pointer;
}

.batch-notify-transcript .cf-chat-option-btn {
  padding: 9px 14px;
  border: 2px solid var(--batch-blue);
  border-radius: 999px;
  background: #fff;
  color: var(--batch-blue);
  font-size: 13px;
  font-weight: 600;
}

.batch-notify-transcript .cf-chat-option-btn.is-selected,
.batch-notify-transcript .cf-chat-option-btn:hover:not(.is-disabled) {
  background: rgba(26, 115, 232, 0.08);
}

.batch-notify-transcript .cf-chat-option-btn.is-selected {
  background: var(--batch-blue);
  color: #fff;
}

.batch-notify-transcript .cf-chat-option-btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.batch-notify-transcript .cf-chat-submit-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.batch-notify-transcript .cf-chat-submit-btn {
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--batch-blue);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

.batch-notify-transcript .cf-chat-typing-dots {
  display: inline-flex;
  gap: 4px;
}

.batch-notify-transcript .cf-chat-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9aa0a6;
  animation: batchNotifyTyping 1.2s infinite ease-in-out;
}

.batch-notify-transcript .cf-chat-typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.batch-notify-transcript .cf-chat-typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes batchNotifyTyping {
  0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

@media (max-width: 640px) {
  .batch-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .batch-search-options-grid {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}
