:root {
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --border-color: #e2e8f0;
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --success: #10b981;
  --error: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

body {
  margin: 0;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.container {
  width: 100%;
  max-width: 800px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
}

.header-content h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text-main);
}

.header-content p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* Env Switcher */
.env-switcher {
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.env-label {
  font-size: 12px;
  color: var(--text-muted);
  padding: 0 8px;
}

.env-btn {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  user-select: none;
}

.env-btn:hover {
  color: var(--text-main);
}

.env-btn.active {
  background: white;
  color: var(--primary-color);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

/* Header Extra */
.header-extra {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.extra-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* Main Card */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow);
  position: relative;
}

.card::before {
  display: none;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text-main);
}

.section-title svg {
  width: 20px;
  height: 20px;
  color: var(--primary-color);
}

/* Inputs Grid */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
}

input,
textarea {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Buttons */
.actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

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

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Loading Spinner */
.btn-loading {
  position: relative;
  pointer-events: none;
}

.btn-loading .btn-text {
  opacity: 0;
}

.btn-loading .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.btn-secondary {
  background-color: white;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

/* Results */
.results-card {
  margin-top: 24px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
}

.result-list {
  margin-top: 16px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 14px;
}

.result-item:last-child {
  margin-bottom: 0;
}

/* State colors for result items */
.result-item.success {
  background-color: #f0fdf4;
  border-color: #bbf7d0;
}

.result-item.error {
  background-color: #fef2f2;
  border-color: #fecaca;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.status-badge.success {
  color: #15803d;
}

.status-badge.error {
  color: #b91c1c;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px;
  font-size: 14px;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px dashed var(--border-color);
}

/* History Panel (dev mode only) */
.history-toggle {
  display: none;
  margin-top: 24px;
}

.history-toggle.visible {
  display: block;
}

.history-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  transition: all 0.2s;
}

.history-btn:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.history-btn.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.history-panel {
  display: none;
  margin-top: 16px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.history-panel.open {
  display: block;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.history-table th {
  text-align: left;
  padding: 10px 12px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-muted);
  font-weight: 500;
}

.history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
}

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

.history-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.history-pagination button {
  padding: 6px 12px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background: white;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-main);
}

.history-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.history-pagination button:hover:not(:disabled) {
  background: #f8fafc;
}

.env-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
  background: #e0e7ff;
  color: #3730a3;
}

@media (max-width: 768px) {
  .grid {
    grid-template-columns: 1fr;
  }

  header {
    flex-direction: column;
    gap: 16px;
  }

  .header-extra {
    width: 100%;
    align-items: flex-start;
    flex-direction: row;
    justify-content: space-between;
  }
}
