:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --text: #e8eef7;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: #334155;
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(160deg, #0b1020 0%, #111827 50%, #0f172a 100%);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }

.view { min-height: 100vh; }
.auth-card {
  max-width: 420px;
  margin: 8vh auto;
  padding: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}

h1, h2, h3 { margin: 0 0 .75rem; }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; }

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; }
.tab {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .6rem;
  border-radius: 8px;
  cursor: pointer;
}
.tab.active { background: var(--primary); border-color: var(--primary); }

label { display: block; margin-bottom: .75rem; font-size: .9rem; color: var(--muted); }
input, select {
  width: 100%;
  margin-top: .35rem;
  padding: .65rem .75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.btn {
  border: none;
  border-radius: 8px;
  padding: .65rem 1rem;
  cursor: pointer;
  font-weight: 600;
}
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: white; }

.error { color: var(--danger); margin-top: 1rem; }
.status-msg { color: var(--muted); margin-top: .75rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15,20,25,.8);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-actions { display: flex; gap: .5rem; }
.dashboard { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}
.stat-card strong { display: block; font-size: 1.75rem; }
.stat-card span { color: var(--muted); font-size: .85rem; }

.upload-form {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
.language-select {
  cursor: pointer;
}

@media (min-width: 700px) {
  .upload-form { grid-template-columns: 1fr 160px; align-items: end; }
}

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  padding: 1rem;
  transition: border-color .15s, background .15s;
}
.file-drop:hover { border-color: var(--primary); background: rgba(59, 130, 246, .08); }
.file-drop input[type="file"] { display: none; }

.upload-queue {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: .5rem;
}
.upload-queue li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .65rem .85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
}
.upload-queue .q-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-queue .q-status { color: var(--muted); flex-shrink: 0; }
.upload-queue .q-status.ok { color: var(--success); }
.upload-queue .q-status.err { color: var(--danger); }
.upload-queue .q-status.busy { color: var(--primary); }

.card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.filters { display: flex; gap: .5rem; flex-wrap: wrap; }
.filters input, .filters select { width: auto; min-width: 140px; margin: 0; }

.jobs-list { display: grid; gap: .75rem; }
.job-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem 1rem;
  padding: 1rem;
  background: var(--surface-2);
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color .15s;
}
.job-item:hover { border-color: var(--primary); }
.job-meta { color: var(--muted); font-size: .85rem; }
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.pending { background: #334155; }
.badge.processing { background: #1d4ed8; }
.badge.completed { background: #166534; }
.badge.failed { background: #991b1b; }

.pagination {
  display: flex;
  justify-content: center;
  gap: .5rem;
  margin-top: 1rem;
}

dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: 700px;
  width: 92%;
  padding: 0;
}
dialog article { padding: 1.25rem; }
dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
#detail-body pre {
  white-space: pre-wrap;
  background: var(--surface-2);
  padding: 1rem;
  border-radius: 8px;
  max-height: 50vh;
  overflow: auto;
}
