:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3f56;
  --text: #e8edf4;
  --text-muted: #8fa3bf;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}

.header {
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.15rem;
}

.mode-badge {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

.mode-badge.browser {
  background: rgba(59, 130, 246, 0.12);
  color: #93c5fd;
}

.mode-badge.server {
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
}

.file-meta {
  margin-top: 0.85rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  font-weight: 600;
}

.card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.06);
}

.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.dropzone-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.dropzone-hint {
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.dropzone-formats {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  text-decoration: underline;
  padding: 0;
}

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

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.field input,
.field select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.field input:focus,
.field select:focus {
  border-color: var(--primary);
}

.field-muted label {
  opacity: 0.55;
}

.field input:disabled,
.field select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.detect-panel {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.detect-panel h3 {
  margin-bottom: 0.75rem;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin: 1rem 0 1.25rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text-muted);
}

.checkbox-label input {
  accent-color: var(--primary);
  width: 1rem;
  height: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

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

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

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

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

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

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat-box {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  text-align: center;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--success);
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.preview-wrap {
  margin-bottom: 1.25rem;
}

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

table.preview {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

table.preview th,
table.preview td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

table.preview th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}

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

.cell-converted {
  color: var(--success);
  font-weight: 600;
}

.cell-skipped {
  color: var(--text-muted);
}

.footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 1rem;
}

.server-status {
  margin-top: 0.35rem;
  font-size: 0.75rem;
}

.server-status.ok {
  color: #86efac;
}

.server-status.warn {
  color: #fcd34d;
}

.loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  gap: 1rem;
}

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

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

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 1000;
  max-width: 360px;
  animation: slideIn 0.25s ease;
}

.toast.error {
  border-color: var(--danger);
  color: #fca5a5;
}

.toast.success {
  border-color: var(--success);
}

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

@media (max-width: 600px) {
  .app {
    padding: 1.25rem 1rem 2rem;
  }

  .dropzone {
    padding: 2rem 1rem;
  }

  .actions {
    justify-content: stretch;
  }

  .btn {
    flex: 1;
    text-align: center;
  }
}
