:root {
  --primary-color: #6366f1;
  --primary-hover: #4f46e5;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  line-height: 1.6;
}

.container {
  max-width: 800px;
  width: 100%;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  text-align: center;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  background: linear-gradient(to right, #818cf8, #c084fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
}

p.subtitle {
  color: var(--text-secondary);
  margin-bottom: 30px;
}

.upload-section {
  border: 2px dashed var(--glass-border);
  border-radius: 16px;
  padding: 40px;
  margin-bottom: 30px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-section:hover {
  border-color: var(--primary-color);
  background: rgba(99, 102, 241, 0.05);
}

#fileInput {
  display: none;
}

.btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  background: #475569;
  cursor: not-allowed;
  transform: none;
}

.ocr-source-status {
  margin-top: 10px;
  color: var(--text-secondary);
  font-size: 0.88rem;
}

.ocr-source-status.is-backend {
  color: #34d399;
}

.ocr-source-status.is-local {
  color: #fbbf24;
}

#result-container {
  margin-top: 40px;
  display: none;
  text-align: left;
}

#table-wrapper {
  margin-top: 20px;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
}

.edit-tip {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.table-preview {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  margin-top: 0;
  background: transparent;
}

.table-preview th, .table-preview td {
  padding: 12px 16px;
  border: 1px solid var(--glass-border);
  font-size: 0.9rem;
  white-space: nowrap;
}

.table-preview td[contenteditable="true"] {
  cursor: text;
  transition: background-color 0.2s ease, outline-color 0.2s ease;
}

.table-preview td[contenteditable="true"]:hover {
  background: rgba(99, 102, 241, 0.12);
}

.table-preview td[contenteditable="true"]:focus {
  outline: 2px solid rgba(129, 140, 248, 0.9);
  outline-offset: -2px;
  background: rgba(99, 102, 241, 0.18);
}

.table-preview th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  text-align: left;
}

.download-link {
  margin-top: 20px;
  display: inline-block;
  text-decoration: none;
  background: #10b981;
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
}

.download-link:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.loading {
  display: none;
  margin: 20px 0;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 10px;
}

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