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

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--gray-50); color: var(--gray-800); min-height: 100vh; }

/* ── Auth ── */
#auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 2.5rem; width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.auth-card p { color: var(--gray-600); font-size: .875rem; margin-bottom: 1.5rem; }
.auth-card label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .4rem; }
.auth-card input { width: 100%; padding: .6rem .75rem; border: 1px solid var(--gray-200); border-radius: 6px; font-size: 1rem; outline: none; }
.auth-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.auth-card button { margin-top: 1rem; width: 100%; }
.auth-error { color: var(--red); font-size: .875rem; margin-top: .75rem; }

/* ── Layout ── */
#app { display: none; }
.topbar { background: white; border-bottom: 1px solid var(--gray-200); padding: .875rem 1.5rem; display: flex; align-items: center; justify-content: space-between; }
.topbar-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; }
.topbar-brand svg { color: var(--blue); }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.quota { font-size: .8rem; color: var(--gray-600); background: var(--gray-100); padding: .3rem .7rem; border-radius: 20px; }
.btn-logout { font-size: .8rem; color: var(--gray-600); background: none; border: none; cursor: pointer; }
.btn-logout:hover { color: var(--red); }

main { max-width: 900px; margin: 0 auto; padding: 2rem 1rem; }

/* ── Upload card ── */
.upload-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem; margin-bottom: 2rem; }
.upload-card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1.25rem; }
.drop-zone {
  border: 2px dashed var(--gray-200); border-radius: 8px;
  padding: 2.5rem 1rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--blue); background: rgba(37,99,235,.03); }
.drop-zone input { display: none; }
.drop-zone .drop-icon { font-size: 2rem; margin-bottom: .5rem; }
.drop-zone p { font-size: .9rem; color: var(--gray-600); }
.drop-zone p strong { color: var(--blue); }
.drop-zone .formats { font-size: .78rem; color: var(--gray-400); margin-top: .35rem; }
.drop-zone .selected-file { font-size: .9rem; color: var(--gray-800); margin-top: .5rem; font-weight: 500; }

.upload-options { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1.25rem; }
.option-group label { display: block; font-size: .8rem; font-weight: 500; color: var(--gray-600); margin-bottom: .4rem; }
.option-group select { width: 100%; padding: .55rem .7rem; border: 1px solid var(--gray-200); border-radius: 6px; font-size: .9rem; background: white; cursor: pointer; }

.mode-picker { margin-top: 1.25rem; }
.mode-picker label { display: block; font-size: .8rem; font-weight: 500; color: var(--gray-600); margin-bottom: .6rem; }
.mode-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
.mode-btn {
  border: 2px solid var(--gray-200); border-radius: 8px; background: white;
  padding: .85rem .5rem; text-align: center; cursor: pointer; transition: border-color .15s;
}
.mode-btn.active { border-color: var(--blue); background: rgba(37,99,235,.04); }
.mode-btn .mode-icon { font-size: 1.5rem; }
.mode-btn .mode-name { font-size: .85rem; font-weight: 600; margin-top: .25rem; }
.mode-btn .mode-desc { font-size: .72rem; color: var(--gray-400); margin-top: .1rem; }

.upload-submit { margin-top: 1.25rem; width: 100%; }
.upload-progress { margin-top: .75rem; }
.progress-bar-wrap { height: 6px; background: var(--gray-100); border-radius: 3px; overflow: hidden; margin-top: .4rem; }
.progress-bar { height: 100%; background: var(--blue); border-radius: 3px; transition: width .3s; }
.progress-label { font-size: .78rem; color: var(--gray-600); }

/* ── Jobs list ── */
.jobs-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.jobs-header h2 { font-size: 1.1rem; font-weight: 600; }
.jobs-empty { text-align: center; padding: 3rem; color: var(--gray-400); font-size: .9rem; background: white; border-radius: var(--radius); }
.job-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.25rem; margin-bottom: .75rem; }
.job-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.job-top-right { display: flex; align-items: center; gap: .6rem; }
.btn-delete {
  background: none; border: none; color: var(--gray-400); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: .2rem .4rem; border-radius: 5px;
}
.btn-delete:hover { color: var(--red); background: #fef2f2; }
.job-name { font-weight: 500; font-size: .95rem; word-break: break-all; }
.job-meta { font-size: .78rem; color: var(--gray-400); margin-top: .2rem; }
.badge {
  display: inline-block; padding: .2rem .55rem; border-radius: 20px; font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-queued { background: var(--gray-100); color: var(--gray-600); }
.badge-processing { background: #eff6ff; color: var(--blue); }
.badge-done { background: #f0fdf4; color: var(--green); }
.badge-error { background: #fef2f2; color: var(--red); }

.job-progress { margin-top: .75rem; }
.job-downloads { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.btn-dl {
  font-size: .78rem; padding: .3rem .75rem; border-radius: 5px; border: 1px solid var(--gray-200);
  background: white; color: var(--gray-600); cursor: pointer; text-decoration: none; font-weight: 500;
}
.btn-dl:hover { background: var(--gray-50); border-color: var(--blue); color: var(--blue); }
.job-error { font-size: .8rem; color: var(--red); margin-top: .5rem; }

/* ── Buttons ── */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .65rem 1.2rem; border-radius: 7px; font-size: .9rem; font-weight: 500; cursor: pointer; border: none; transition: background .15s; }
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 540px) {
  .upload-options { grid-template-columns: 1fr; }
  .mode-options { grid-template-columns: repeat(3,1fr); }
}
