* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --gray: #6b7280;
  --light-gray: #f3f4f6;
  --border: #e5e7eb;
  --bg: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --text: #f9fafb;
    --text-muted: #9ca3af;
    --light-gray: #1f2937;
    --border: #374151;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--light-gray);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: var(--bg);
  padding: 1.25rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

/* Main */
.main {
  flex: 1;
  padding: 1.5rem 1rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

/* Query Section */
.query-section {
  margin-bottom: 1.5rem;
}

.query-box {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
}

.input-group {
  display: flex;
  gap: 0.75rem;
}

.input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input::placeholder {
  color: var(--text-muted);
}

.btn {
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

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

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  background: var(--gray);
  cursor: not-allowed;
}

/* Result Section */
.result-section {
  animation: fadeIn 0.3s ease;
}

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

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem;
  color: var(--text-muted);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.error-msg {
  padding: 1rem;
  background: #fef2f2;
  color: var(--error);
  border-radius: var(--radius);
  text-align: center;
  border: 1px solid #fecaca;
}

.empty-msg {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Order List */
.order-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.order-card {
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.order-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.order-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--light-gray);
  border-bottom: 1px solid var(--border);
}

.order-id {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-family: monospace;
}

.order-status {
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
}

.status-progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-done {
  background: #dcfce7;
  color: #16a34a;
}

.status-pending {
  background: #fef3c7;
  color: #d97706;
}

.status-cancel {
  background: #fee2e2;
  color: #dc2626;
}

.status-error {
  background: #fee2e2;
  color: #dc2626;
}

.status-default {
  background: var(--light-gray);
  color: var(--text-muted);
}

.order-body {
  padding: 1rem 1.25rem;
}

.order-row {
  display: flex;
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border);
}

.order-row:last-child {
  border-bottom: none;
}

.order-row .label {
  width: 80px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.order-row .value {
  flex: 1;
  color: var(--text);
  font-size: 0.875rem;
  word-break: break-all;
}

.progress-value {
  font-family: monospace;
  font-size: 0.8rem !important;
}

.order-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--light-gray);
  flex-wrap: wrap;
  gap: 0.5rem;
}

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

/* Refresh Button */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

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

.refresh-btn:active {
  transform: scale(0.95);
}

.refresh-btn:disabled {
  background: var(--gray);
  cursor: not-allowed;
}

.refresh-icon {
  font-size: 0.9rem;
}

.refresh-icon.spinning {
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

.success-icon {
  color: #22c55e;
}

/* Footer */
.footer {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
}

/* Responsive - Tablet and Desktop */
@media (min-width: 640px) {
  .header {
    padding: 1.5rem;
  }

  .title {
    font-size: 1.5rem;
  }

  .main {
    padding: 2rem;
  }

  .query-box {
    padding: 1.5rem;
  }

  .input {
    padding: 1rem 1.25rem;
    font-size: 1rem;
  }

  .btn {
    padding: 1rem 2rem;
  }

  .order-header {
    padding: 1.25rem 1.5rem;
  }

  .order-body {
    padding: 1.25rem 1.5rem;
  }

  .order-footer {
    padding: 1rem 1.5rem;
  }

  .order-row .label {
    width: 100px;
  }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
  .header {
    padding: 1rem;
  }

  .title {
    font-size: 1.125rem;
  }

  .main {
    padding: 1rem;
  }

  .query-box {
    padding: 1rem;
  }

  .input-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    padding: 0.875rem;
  }

  .order-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .order-id {
    word-break: break-all;
  }

  .order-row {
    flex-direction: column;
    gap: 0.25rem;
  }

  .order-row .label {
    width: auto;
    font-size: 0.75rem;
  }

  .order-row .value {
    font-size: 0.8rem;
  }

  .order-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .refresh-btn {
    width: 100%;
    justify-content: center;
    padding: 0.6rem;
    font-size: 0.85rem;
  }
}
