:root {
  --bg: #0a0c10;
  --surface: #161b22;
  --surface-2: #0d1117;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #3d60fa;
  --accent-2: #60a5fa;
  --danger: #ef4444;
  --success: #10b981;
  --border: #1e293b;
  --scrollbar-track: rgba(11, 17, 32, 0.82);
  --scrollbar-track-border: rgba(59, 77, 117, 0.45);
  --scrollbar-thumb-start: #5f7bff;
  --scrollbar-thumb-end: #3553dc;
  --scrollbar-thumb-hover-start: #7690ff;
  --scrollbar-thumb-hover-end: #4665ec;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-start) var(--scrollbar-track);
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border: 1px solid var(--scrollbar-track-border);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--scrollbar-thumb-start), var(--scrollbar-thumb-end));
  border-radius: 999px;
  border: 2px solid rgba(11, 17, 32, 0.82);
  background-clip: padding-box;
  min-height: 28px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--scrollbar-thumb-hover-start), var(--scrollbar-thumb-hover-end));
}

*::-webkit-scrollbar-thumb:active {
  background: linear-gradient(180deg, #8ca3ff, #5271f0);
}

*::-webkit-scrollbar-corner {
  background: var(--scrollbar-track);
}

body {
  margin: 0;
  background: radial-gradient(circle at 20% 15%, rgba(61, 96, 250, 0.16), transparent 35%), var(--bg);
  color: var(--text);
  font-family: "Inter", "Segoe UI", sans-serif;
  min-height: 100vh;
}

body.has-global-loader {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 12, 16, 0.9);
  backdrop-filter: blur(8px);
}

.header-inner {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  background: #111827;
}

.tabs {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px;
  border-radius: 999px;
}

.tab-link {
  padding: 8px 16px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 14px;
  transition: 0.2s ease;
}

.tab-link.active,
.tab-link:hover {
  color: #fff;
  background: rgba(61, 96, 250, 0.2);
}

.user-box {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.user-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #1d4ed8);
  color: #fff;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.page {
  width: min(1360px, calc(100% - 32px));
  margin: 28px auto 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

.card-pad {
  padding: 24px;
}

.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.title-row h1 {
  margin: 0;
  font-size: 28px;
}

.title-row p {
  margin: 6px 0 0;
  color: var(--muted);
}

.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  transition: 0.2s ease;
}

.btn:hover {
  border-color: #334155;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.2);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #3455dd);
  border-color: #3b4cca;
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.06);
}

.btn-danger {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fecaca;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.08);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.table th {
  color: var(--muted);
  font-weight: 500;
}

.bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 8px 0 14px;
  padding: 12px 14px;
  border: 1px solid #22314a;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(61, 96, 250, 0.14), rgba(13, 17, 23, 0.45));
}

.bulk-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.selection-count {
  color: #c7d2fe;
  font-weight: 600;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check-cell {
  width: 44px;
  text-align: center;
}

.pretty-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 20px;
  height: 20px;
}

.pretty-check input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.pretty-check span {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  border: 1px solid #3b4f70;
  background: #0b1220;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: 0.2s ease;
}

.pretty-check input:checked + span {
  background: linear-gradient(135deg, var(--accent), #3455dd);
  border-color: #5c77ff;
}

.pretty-check input:checked + span::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.pretty-check input:disabled + span {
  opacity: 0.4;
  cursor: not-allowed;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
}

.table-actions .btn {
  flex: 1 1 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid transparent;
}

.badge.processing {
  color: #93c5fd;
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(59, 130, 246, 0.14);
}

.badge.done {
  color: #86efac;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.14);
}

.badge.failed {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.14);
}

.status-stack {
  display: grid;
  gap: 6px;
  width: min(220px, 100%);
}

.progress-line {
  height: 6px;
  width: 100%;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  background: rgba(59, 130, 246, 0.1);
  overflow: hidden;
}

.progress-line span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #3d60fa, #60a5fa);
  transition: width 0.3s ease;
}

.processing-time {
  color: #cbd5e1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.processing-time.queued {
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 20px;
  z-index: 80;
}

.modal.open {
  display: flex;
}

.global-loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 8, 15, 0.72);
  backdrop-filter: blur(6px);
}

.global-loader.open {
  display: flex;
}

.global-loader-card {
  width: min(560px, 100%);
  display: grid;
  justify-items: stretch;
  gap: 14px;
  padding: 22px 20px;
  border-radius: 14px;
  border: 1px solid #2a3d62;
  background: linear-gradient(145deg, #101826, #0a111d);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.global-loader-card p {
  margin: 0;
  color: #d8e3f3;
  text-align: center;
  font-size: 14px;
}

.global-loader-details {
  display: none;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}

.global-loader-details.open {
  display: grid;
}

.global-loader-detail-row {
  font-size: 13px;
  color: #dbe7ff;
  border: 1px solid rgba(100, 116, 139, 0.45);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  padding: 8px 10px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.global-loader-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(130, 160, 255, 0.28);
  border-top-color: #6f8dff;
  animation: loader-spin 0.85s linear infinite;
}

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

.modal-card {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
}

.modal-card h2 {
  margin: 0 0 16px;
}

.form-field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.form-field label {
  color: var(--muted);
  font-size: 13px;
}

.form-hint {
  color: var(--muted);
  font-size: 12px;
}

.upload-files-list {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow-y: auto;
  padding-right: 4px;
}

.upload-file-item {
  background: var(--surface-2);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.upload-file-original {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.upload-file-name {
  margin: 0;
}

.input,
.select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid #334155;
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
}

.input[type="file"] {
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
}

.input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #3b4cca;
  background: linear-gradient(135deg, var(--accent), #3455dd);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.input[type="file"]::file-selector-button:hover {
  filter: brightness(1.06);
}

.input[type="file"]::-webkit-file-upload-button {
  margin-right: 12px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #3b4cca;
  background: linear-gradient(135deg, var(--accent), #3455dd);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.modal-actions {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.alert {
  margin-top: 12px;
  min-height: 20px;
  color: #fca5a5;
  font-size: 13px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 30px;
}

.login-card h1 {
  margin-top: 0;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 20px;
}

.login-foot {
  margin-top: 14px;
  min-height: 20px;
  color: #fca5a5;
  font-size: 13px;
}

@media (max-width: 860px) {
  .header-inner {
    height: auto;
    padding: 12px 0;
    flex-wrap: wrap;
    justify-content: center;
  }

  .tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .title-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .table {
    font-size: 12px;
  }

  .bulk-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .bulk-actions {
    width: 100%;
  }
}
