:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --border: #dde1ea;
  --border-hover: #b0b8cc;
  --accent: #2563eb;
  --accent-glow: rgba(37, 99, 235, 0.12);
  --accent-2: #7c3aed;
  --success: #059669;
  --danger: #dc2626;
  --warning: #d97706;
  --text: #111827;
  --text-muted: #4b5563;
  --text-dim: #9ca3af;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Space Grotesk', sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.12);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(37,99,235,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(124,58,237,0.04) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

.noise-overlay {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  opacity: 0.15;
  pointer-events: none;
  z-index: 1;
}

.site-header {
  position: relative;
  z-index: 10;
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
}

.main-content {
  flex: 1;
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  padding: 3rem 1.25rem 4rem;
}

.site-footer {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 1.25rem;
  color: var(--text-dim);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ---- UPLOAD PAGE ---- */
.page-upload {
  width: 100%;
  max-width: 560px;
}

.hero { margin-bottom: 2rem; }

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
}

.hero-title em {
  font-style: normal;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  margin-top: 0.75rem;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 300;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.upload-card--disabled {
  opacity: 0.5;
  pointer-events: none;
  user-select: none;
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  position: relative;
  background: var(--surface-2);
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(79,139,255,0.05);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.drop-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.drop-label { font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--text); }
.drop-sub { font-size: 0.875rem; color: var(--text-muted); margin-top: 0.25rem; }
.drop-hint { font-size: 0.78rem; color: var(--text-dim); margin-top: 0.5rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* File chip */
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.4rem 1rem 0.4rem 0.75rem;
  font-size: 0.875rem;
  max-width: 100%;
}

.file-chip__icon { font-size: 1rem; flex-shrink: 0; }
.file-chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.file-chip__remove {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0 0 0 0.25rem;
  flex-shrink: 0;
  transition: color 0.15s;
}
.file-chip__remove:hover { color: var(--danger); }

/* Notice bar */
.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 1.25rem;
}

.notice-bar--urgent {
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.25);
}

.notice-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* Password input */
.form-section {
  margin-top: 1.25rem;
  position: relative;
}

.form-label-custom {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}

.input-custom {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 3rem 0.7rem 1rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-custom:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.btn-toggle-pass {
  position: absolute;
  right: 0.75rem;
  bottom: 0.65rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.5;
  transition: opacity 0.15s;
}
.btn-toggle-pass:hover { opacity: 1; }

/* Submit button */
.btn-submit {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  position: relative;
}

.btn-submit:hover:not(:disabled) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(79,139,255,0.35);
}

.btn-submit:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

  .btn-install {
    padding: 0.7rem 1rem;
    border: 1px solid rgba(37, 99, 235, 0.18);
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  }

  .btn-install:hover {
    background: rgba(37, 99, 235, 0.14);
    transform: translateY(-1px);
  }
.error-msg {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 50;
  width: min(92%, 420px);
  margin: 0;
  padding: 0.85rem 1rem 0.85rem 4.2rem;
  background: rgba(248, 113, 113, 0.95);
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.95rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(10px);
  background-image: url('/static/img/android-chrome-192x192.png');
  background-repeat: no-repeat;
  background-position: 1rem center;
  background-size: 2rem 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.feature-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0.35rem 0.85rem;
}

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

/* Alert banner */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border-radius: var(--radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.alert-banner--busy {
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(251,191,36,0.3);
  color: var(--warning);
}

.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

/* ---- JOB PAGE ---- */
.page-job {
  width: 100%;
  max-width: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.job-state {
  text-align: center;
  width: 100%;
  animation: fadeUp 0.4s ease both;
}

.state-icon {
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
  display: block;
}

.state-icon--spin { animation: rockSpin 2s ease-in-out infinite; }
.state-icon--done { color: var(--success); animation: popIn 0.5s cubic-bezier(0.34,1.56,0.64,1) both; }
.state-icon--error { color: var(--danger); }

.state-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.state-sub {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.state-hint {
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-top: 1rem;
}

/* Progress track */
.progress-track {
  height: 4px;
  background: var(--surface-2);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar-custom {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 100px;
  transition: width 0.5s ease;
  width: 0%;
}

.progress-bar-custom--indeterminate {
  width: 40% !important;
  animation: indeterminate 1.4s ease-in-out infinite;
}

/* Spinner ring */
.spinner-ring {
  width: 56px;
  height: 56px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  margin: 0 auto;
}

/* Download button */
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.9rem 2rem;
  background: linear-gradient(135deg, var(--success), #059669);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  margin-top: 0.5rem;
}

.btn-download:hover {
  opacity: 0.92;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(52, 211, 153, 0.3);
  color: #fff;
}

.back-link {
  margin-top: 1.75rem;
  font-size: 0.875rem;
}

.back-link a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.back-link a:hover { color: var(--accent); }

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

@keyframes rockSpin {
  0%, 100% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
}

@keyframes indeterminate {
  0% { transform: translateX(-200%); }
  100% { transform: translateX(400%); }
}

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

@keyframes popIn {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* ---- ADMIN PAGE ---- */
.admin-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.admin-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--text);
}

.admin-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.admin-stats span {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.admin-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

.admin-loader .spinner-ring {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.admin-table th,
.admin-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table tbody tr:hover {
  background: rgba(37, 99, 235, 0.02);
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-queued { background: rgba(251, 191, 36, 0.1); color: #d97706; }
.status-processing { background: rgba(59, 130, 246, 0.1); color: #2563eb; }
.status-done { background: rgba(34, 197, 94, 0.1); color: #059669; }
.status-error { background: rgba(239, 68, 68, 0.1); color: #dc2626; }

.deleted-badge {
  display: inline-flex;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.deleted-yes { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
.deleted-no { background: rgba(34, 197, 94, 0.1); color: #059669; }

.flash {
  animation: flash 1s ease-in-out;
}

@keyframes flash {
  0%, 100% { background: rgba(37, 99, 235, 0.1); }
  50% { background: rgba(37, 99, 235, 0.3); }
}

/* ---- AUTH PAGE ---- */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 70vh;
  padding: 2rem 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.auth-sub {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 2rem;
}

.auth-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
}

.auth-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-btn {
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s;
}

.auth-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 576px) {
  .main-content { padding: 2rem 1rem 3rem; }
  .card { padding: 1.5rem 1.25rem; }
  .hero-title { font-size: 2rem; }
  .features-row { gap: 0.5rem; }
  .feature-item { font-size: 0.72rem; }
}