* { box-sizing: border-box; }

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e6e8f0;
  --text: #16181d;
  --text-muted: #6b7280;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success-bg: #ecfdf3;
  --success-text: #027a48;
  --warning-bg: #fffaeb;
  --warning-text: #b54708;
  --failed-bg: #fef3f2;
  --failed-text: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 8px rgba(16, 24, 40, 0.06), 0 2px 4px rgba(16, 24, 40, 0.04);
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Login ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: radial-gradient(circle at top, #eef1ff 0%, var(--bg) 55%);
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  padding: 2.5rem 2.25rem;
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 420px;
}
.login-card .brand {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}
.login-card .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}
.login-card .brand-logo {
  max-height: 72px;
  max-width: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 0;
}
.login-card h1 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}
.login-card label {
  display: block;
  margin-bottom: 1.1rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}
.login-card input {
  display: block;
  width: 100%;
  padding: 0.65rem 0.8rem;
  margin-top: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.login-card button {
  width: 100%;
  padding: 0.7rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.login-card button:hover { background: var(--primary-hover); }
.login-extra {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.85rem;
}
.login-extra a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.login-extra a:hover { text-decoration: underline; }
.hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.error {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0 0 1.1rem;
}

/* ---------- Shell ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 2rem;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.topbar-logo {
  max-height: 52px;
  max-width: 260px;
  width: auto;
  height: auto;
  object-fit: contain;
}
.topbar h1 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.btn-ghost {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.success-msg {
  background: var(--success-bg);
  color: var(--success-text);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin: 0 0 1.1rem;
}

main {
  max-width: 960px;
  margin: 2.5rem auto;
  padding: 0 1.5rem 4rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem;
}
.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
}

/* ---------- Upload form ---------- */
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.field { margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.field input[type="text"],
.field input[type="password"],
.field input[type="email"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.field input[type="text"]:focus,
.field input[type="password"]:focus,
.field input[type="email"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  border: 1.5px dashed var(--border);
  border-radius: 10px;
  padding: 1.75rem 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  transition: border-color .15s, background .15s;
  position: relative;
  margin-bottom: 1.25rem;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.dropzone .dz-icon {
  font-size: 1.4rem;
  margin-bottom: 0.4rem;
}
.dropzone .dz-text {
  font-size: 0.88rem;
  color: var(--text-muted);
}
.dropzone .dz-text strong { color: var(--primary); font-weight: 600; }
.dropzone .dz-filename {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.btn-primary {
  padding: 0.65rem 1.3rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

#upload-status {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
#upload-status.is-error { color: var(--danger); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  padding: 0 0.75rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.9rem 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
.cell-muted { color: var(--text-muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.status-ready { background: var(--success-bg); color: var(--success-text); }
.badge.status-processing { background: var(--warning-bg); color: var(--warning-text); }
.badge.status-failed { background: var(--failed-bg); color: var(--failed-text); }

.row-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}
.delete-btn, .preview-btn {
  background: none;
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.delete-btn { color: var(--danger); }
.delete-btn:hover { background: var(--danger-soft); border-color: var(--danger); }
.preview-btn { color: var(--primary); }
.preview-btn:hover { background: var(--primary-soft); border-color: var(--primary); }

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  main { margin: 1.5rem auto; }
  .card { padding: 1.25rem; }
}
