.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  border: 1px solid var(--border);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-stat {
  position: relative;
  overflow: hidden;
}

.card-stat::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  opacity: 0.85;
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.card-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  font-family: var(--font);
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg);
  border-color: #CBD5E1;
  color: var(--text);
}

.btn-danger {
  background: var(--error);
  color: white;
}

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

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input::placeholder {
  color: #94A3B8;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

.form-textarea { resize: vertical; min-height: 110px; }

.form-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.template-input-tabs {
  margin-top: 4px;
}

.template-input-tabs .page-tabs {
  margin-bottom: 16px;
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(calc(100% + 24px));
  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-leaving {
  opacity: 0;
  transform: translateX(calc(100% + 24px));
  transition: opacity 0.2s ease, transform 0.25s ease;
}

.toast-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

.toast-icon svg {
  width: 22px;
  height: 22px;
}

.toast-success .toast-icon { color: var(--accent); }
.toast-error .toast-icon { color: var(--error); }
.toast-info .toast-icon { color: #2563EB; }
.toast-warning .toast-icon { color: var(--warning); }

.toast-body {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
  letter-spacing: -0.01em;
}

.toast-message {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  word-break: break-word;
}

.toast-message code {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.75rem;
  word-break: break-all;
  border: 1px solid var(--border);
  color: var(--text);
}

.toast-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  margin: -4px -6px 0 0;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  background: var(--bg);
  color: var(--text);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform-origin: left;
  animation: toastProgress linear forwards;
}

.toast-success .toast-progress { background: var(--accent); }
.toast-error .toast-progress { background: var(--error); }
.toast-info .toast-progress { background: #2563EB; }
.toast-warning .toast-progress { background: var(--warning); }

@keyframes toastProgress {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

th, td {
  padding: 14px 18px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

tr:last-child td { border-bottom: none; }

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: #FAFBFC;
}

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: #FAFBFC;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-success { background: var(--accent-soft); color: var(--accent-hover); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-muted { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

.dropzone {
  border: 2px dashed #CBD5E1;
  border-radius: var(--radius);
  padding: 52px 28px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: linear-gradient(180deg, #FAFBFC 0%, var(--surface) 100%);
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.dropzone-icon {
  font-size: 2.25rem;
  margin-bottom: 14px;
  color: var(--accent);
  line-height: 1;
}

.dropzone-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.preview-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
  margin-top: 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.preview-wrap-file {
  display: block;
  width: 100%;
  padding: 20px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
}

.preview-wrap-file .file-preview-name {
  margin: 0;
}

.preview-image {
  display: block;
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.preview-processing-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: previewOverlayIn 0.25s ease;
}

.preview-wrap.is-processing .preview-processing-overlay {
  display: flex;
}

.preview-wrap.is-processing .preview-image {
  animation: previewPulse 2s ease-in-out infinite;
}

.preview-scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, #34D399, #10B981, #34D399, transparent);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.9), 0 0 4px rgba(255, 255, 255, 0.5);
  animation: previewScan 2.2s ease-in-out infinite;
}

.preview-processing-label {
  position: relative;
  z-index: 1;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(4px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.preview-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: previewSpin 0.75s linear infinite;
  flex-shrink: 0;
}

@keyframes previewOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes previewScan {
  0% { top: 0; opacity: 0.5; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: calc(100% - 4px); opacity: 0.5; }
}

@keyframes previewPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(0.88); }
}

@keyframes previewSpin {
  to { transform: rotate(360deg); }
}

.progress-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
  margin: 18px 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
  animation: progress 1.5s ease-in-out infinite;
}

@keyframes progress {
  0% { width: 0%; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

.result-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
}

.result-tab {
  padding: 8px 14px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 8px;
  transition: all var(--transition);
  font-family: var(--font);
}

.result-tab:hover { color: var(--text-secondary); }

.result-tab.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.result-content {
  background: #F8FAFC;
  border-radius: var(--radius-sm);
  padding: 18px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.result-excel-ready {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 40px 24px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.result-excel-icon {
  font-size: 2.5rem;
  color: var(--accent);
  margin-bottom: 12px;
}

.result-excel-icon-svg {
  font-size: 2.5rem;
}

.result-excel-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.result-excel-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 8px;
}

.result-excel-name {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin: 0 0 20px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
  font-size: 0.925rem;
  line-height: 1.7;
}

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }

.page-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
  padding: 5px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
  box-shadow: var(--shadow-xs);
}

.page-tab {
  padding: 10px 20px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  border-radius: 8px;
  font-family: var(--font);
  transition: all var(--transition);
}

.page-tab:hover {
  color: var(--text-secondary);
  background: var(--bg);
}

.page-tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.page-tab-panel {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-search-select { position: relative; }

.user-search-input-wrap { position: relative; }

.user-search-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: all var(--transition);
}

.user-search-clear:hover {
  background: var(--border);
  color: var(--text);
}

.user-search-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 280px;
  overflow-y: auto;
}

.user-search-option {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font);
  transition: background var(--transition);
}

.user-search-option:last-child { border-bottom: none; }

.user-search-option:hover { background: var(--accent-soft); }

.user-search-option-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text);
}

.user-search-option-email {
  grid-column: 1;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.user-search-option-balance {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
}

.user-search-empty {
  padding: 14px;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.user-search-selected-card {
  padding: 12px 14px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.user-search-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Upload mode toggle */
.upload-mode-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
}

.upload-mode-btn {
  padding: 8px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.8125rem;
  cursor: pointer;
  border-radius: 8px;
  font-family: var(--font);
  transition: all var(--transition);
}

.upload-mode-btn.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

/* Batch dropzone */
.batch-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 32px 24px;
  text-align: center;
  cursor: default;
  transition: all var(--transition);
  background: var(--bg-subtle);
}

.batch-dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.batch-dropzone-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.batch-dropzone-hint,
.upload-pdf-hint {
  margin: 12px 0 0;
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.45;
  opacity: 0.85;
}

.batch-picker-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--bg-subtle);
}

.batch-picker-summary {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.batch-picker-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.batch-picker-item {
  display: grid;
  grid-template-columns: 28px 52px 1fr 64px 32px;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}

.batch-picker-num { color: var(--text-muted); font-weight: 600; }
.batch-picker-type { color: var(--accent); font-size: 0.75rem; font-weight: 600; }
.batch-picker-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-picker-size { color: var(--text-muted); font-size: 0.75rem; text-align: right; }

.batch-summary {
  padding: 14px 16px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.batch-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  margin-bottom: 6px;
}

.batch-summary-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Batch progress */
.batch-progress-panel {
  margin-top: 16px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  animation: fadeIn 0.3s ease;
}

.batch-progress-title {
  font-size: 1rem;
  font-weight: 700;
}

.batch-progress-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.batch-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0;
  flex-wrap: wrap;
}

.batch-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.batch-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
}

.batch-step--active .batch-step-dot {
  background: var(--accent);
  animation: batchStepPulse 1.5s ease-in-out infinite;
}

.batch-step--done .batch-step-dot {
  background: var(--accent);
}

.batch-step--active .batch-step-label,
.batch-step--done .batch-step-label {
  color: var(--text);
  font-weight: 600;
}

.batch-step-line {
  width: 24px;
  height: 2px;
  background: var(--border);
}

.batch-progress-bar {
  height: 8px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
}

.batch-progress-bar-fill {
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 999px;
  transition: width 0.4s ease;
  width: 0;
}

.batch-progress-meta {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.batch-progress-failed { color: var(--error); }
.batch-progress-cost { color: var(--accent); font-weight: 600; }

.batch-current-file {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  padding: 12px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
}

.batch-current-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.batch-current-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.batch-file-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--border-light);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.batch-file-thumb--active {
  border: 2px solid var(--accent);
}

.batch-file-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.batch-file-item {
  display: grid;
  grid-template-columns: 28px 24px 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.8125rem;
  transition: all 0.25s ease;
}

.batch-file-item--active {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
}

.batch-file-item--done {
  opacity: 0.75;
}

.batch-file-item--failed {
  background: rgba(239, 68, 68, 0.08);
  animation: batchShake 0.4s ease;
}

.batch-file-index { color: var(--text-muted); font-weight: 600; }
.batch-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-status-spinner { width: 14px; height: 14px; border-width: 2px; }

.batch-interrupted-banner {
  margin-top: 12px;
  padding: 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: var(--error);
  font-size: 0.875rem;
}

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

@keyframes batchShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  .batch-file-item--failed { animation: none; }
  .batch-step--active .batch-step-dot { animation: none; }
  .batch-progress-panel { animation: none; }
}
