:root {
  --bg-canvas: #f6f8fc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-light: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --emerald-600: #059669;
  --emerald-50: #ecfdf5;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --rose-600: #e11d48;
  --rose-50: #fff1f2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px -2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 12px 32px -8px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 54px -12px rgba(15, 23, 42, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.mono {
  font-family: "SF Mono", "JetBrains Mono", Menlo, Monaco, Consolas, monospace;
}

.hidden {
  display: none !important;
}

/* ---------- Toast Notifications ---------- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  background: #0f172a;
  color: #ffffff;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.success { background: #065f46; }
.toast.error { background: #9f1239; }
.toast.info { background: #1e293b; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- Auth Layout ---------- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
  background:
    radial-gradient(900px circle at 12% 15%, rgba(37, 99, 235, 0.08), transparent 55%),
    radial-gradient(800px circle at 88% 85%, rgba(14, 165, 233, 0.08), transparent 55%),
    var(--bg-canvas);
}

.auth-shell {
  width: 100%;
  max-width: 980px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  overflow: hidden;
}

@media (max-width: 840px) {
  .auth-shell {
    grid-template-columns: 1fr;
    max-width: 460px;
  }
  .auth-showcase {
    display: none;
  }
}

.auth-showcase {
  background: linear-gradient(145deg, #0b1120 0%, #172554 55%, #1e3a8a 100%);
  color: #ffffff;
  padding: 46px 42px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-showcase::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96, 165, 250, 0.25) 0%, transparent 70%);
  pointer-events: none;
}

.showcase-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 11.5px;
  letter-spacing: 0.8px;
  font-weight: 600;
  width: fit-content;
}

.showcase-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  margin: 22px 0 12px;
  letter-spacing: -0.3px;
}

.showcase-desc {
  color: rgba(226, 232, 240, 0.82);
  font-size: 14px;
  margin: 0 0 32px;
  line-height: 1.65;
}

.feature-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.feature-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.22);
  border: 1px solid rgba(147, 197, 253, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #93c5fd;
}

.feature-item h4 {
  margin: 0 0 3px;
  font-size: 14px;
  font-weight: 600;
  color: #f8fafc;
}

.feature-item p {
  margin: 0;
  font-size: 12.5px;
  color: rgba(203, 213, 225, 0.8);
}

.showcase-footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: rgba(148, 163, 184, 0.9);
  display: flex;
  justify-content: space-between;
}

.auth-panel {
  padding: 42px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-tabs {
  display: flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 26px;
}

.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.16s ease;
}

.auth-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* ---------- Form Elements ---------- */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 11.5px;
  font-weight: 400;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-control {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: #ffffff;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-control:focus {
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-control::placeholder {
  color: #94a3b8;
}

.domain-pill {
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.domain-pill.valid { color: var(--emerald-600); }
.domain-pill.invalid { color: var(--rose-600); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.16s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #1d4ed8 0%, #1e40af 100%);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border-color: var(--border-light);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}

.btn-emerald {
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(5, 150, 105, 0.22);
}

.btn-emerald:hover:not(:disabled) {
  filter: brightness(0.96);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--rose-600);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--rose-50);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 7px;
}

.btn-block {
  width: 100%;
}

/* ---------- App Navbar & Shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
}

.topbar-inner {
  max-width: 1260px;
  margin: 0 auto;
  height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.nav-pills {
  display: flex;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 10px;
}

.nav-pill {
  border: none;
  background: transparent;
  padding: 7px 15px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.nav-pill.active {
  background: var(--bg-surface);
  color: var(--brand-700);
  box-shadow: var(--shadow-xs);
}

.pill-count {
  background: var(--brand-100);
  color: var(--brand-700);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 6px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color 0.15s;
}

.user-chip:hover {
  border-color: var(--border-strong);
}

.user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-50);
  color: var(--brand-700);
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* ---------- Cards & Upload Dropzone ---------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 22px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fafcff 0%, #f4f7fc 100%);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--brand-600);
  background: var(--brand-50);
}

.dropzone-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-xs);
  color: var(--brand-600);
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-title {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.dropzone-hint {
  font-size: 12.5px;
  color: var(--text-muted);
}

.selected-file-bar {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid var(--brand-100);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--brand-700);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 20px;
}

@media (max-width: 900px) {
  .meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 540px) {
  .meta-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Progress Panel ---------- */
.progress-box {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-md);
}

.progress-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #34d399);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* ---------- KPI Grid ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
}

.kpi-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 25px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.4px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Badges & Tables ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-blue { background: var(--brand-50); color: var(--brand-700); }
.badge-green { background: var(--emerald-50); color: var(--emerald-600); }
.badge-amber { background: var(--amber-50); color: var(--amber-600); }
.badge-rose { background: var(--rose-50); color: var(--rose-600); }
.badge-slate { background: var(--bg-subtle); color: var(--text-secondary); }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #ffffff;
}

table.data-table th {
  background: #f8fafc;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

table.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text-primary);
}

table.data-table tr:last-child td {
  border-bottom: none;
}

table.data-table tbody tr:hover {
  background: #f8fafc;
}

.cell-truncate {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Category Distribution Chips ---------- */
.cat-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.cat-chip {
  background: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.cat-chip:hover, .cat-chip.active {
  background: var(--brand-50);
  border-color: var(--brand-600);
  color: var(--brand-700);
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-box {
  width: 100%;
  max-width: 480px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 26px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}
