:root {
  --bg-primary: #edf2ff;
  --bg-secondary: #ffffff;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #3b82f6;
  --card-bg: #ffffff;
  --card-bg-light: #f1f5f9;
  --border-color: rgba(15, 23, 42, 0.12);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --success: #10b981;
  --warning: #f59e0b;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg-primary) 100%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 1rem 3rem;
  gap: 2rem;
}

body.login-page {
  padding-top: 1.5rem;
}

.app-header {
  width: min(1200px, 100%);
  margin: 0 auto;
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 1.25rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
}

.detail-line {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.logo-image {
  height: 54px;
  width: auto;
}

.logo-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.15px;
}

.logo-subtitle {
  font-size: 0.8rem;
  color: #74dbe8;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-btn {
  background: transparent;
  color: #1e283e;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  border: 1px solid rgba(15, 23, 42, 0.1);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.nav-btn:hover {
  background: rgba(37, 99, 235, 0.08);
  color: white;
  box-shadow: none;
}

.nav-btn-logout {
  background: #e71708;
  color: #f1f0ef;
}

.nav-btn-logout:hover {
  background: #f5130b;
  color: #fff;
}

.page-content {
  width: min(1200px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-page .page-content {
  flex: 1;
  min-height: calc(100vh - 220px);
  justify-content: center;
}

.table-card {
  width: 100%;
  background: #fff;
  border-radius: 24px;
  padding: 1.5rem 1.5rem 2.5rem;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
}


.table-card__header {
  margin-bottom: 1.25rem;
}

.table-card__header h1 {
  margin: 0;
  font-size: 1rem;
}

.table-card__header p {
  margin: 0.35rem 0 0;
  color: var(--text-secondary);
  font-size: 1 rem;
}

.link-cell {
  text-align: center;
}

.timestamp-cell {
  color: var(--text-secondary);
  min-width: 160px;
}

/* Upload Card */
.upload-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 420px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.12);
  transition: all 0.3s ease;
  margin-bottom: 2rem;
}

.upload-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 26px 60px rgba(15, 23, 42, 0.18);
}

h1 {
  margin-bottom: 1.5rem;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.5px;
}

/* Drop Area */
#dropArea {
  border: 2px dashed rgba(15, 23, 42, 0.15);
  border-radius: 14px;
  padding: 2.2rem 1rem;
  margin-bottom: 1.3rem;
  background: var(--card-bg-light);
  transition: all 0.3s ease;
}

#dropArea.dragover {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--accent);
}

input[type="file"] {
  display: none;
}

#fileLabel {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 1rem;
  transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.2s ease;
}

#fileLabel:hover {
  transform: scale(1.05);
  background: var(--accent-hover);
  box-shadow: 0 4px 25px rgba(59, 130, 246, 0.4);
}

#fileList {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

/* Buttons */
button {
  padding: 0.7rem 1.5rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

button:hover:enabled {
  transform: translateY(-2px);
  background: var(--accent-hover);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#message {
  margin-top: 1rem;
  font-weight: 500;
  min-height: 1.2em;
  color: var(--accent);
}

/* Loader */
.loader {
  border: 4px solid rgba(37, 99, 235, 0.15);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  animation: spin 1s linear infinite;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 10;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Table */
table.dataTable {
  background: var(--card-bg);
  border-radius: 14px;
  border: 1px solid var(--border-color);
  margin-top: 2.5rem !important;
  width: 100% !important;
  overflow: hidden;
}

table.dataTable th {
  background: #eff4ff;
  color: var(--accent);
  font-weight: 600;
  text-transform: none !important;
  letter-spacing: 0.5px;
  padding: 1rem 1.2rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

table.dataTable td {
  color: var(--text-primary);
  padding: 0.9rem 1.2rem;
  line-height: 1.4;
  font-size: 0.92rem;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.dataTables_wrapper .dataTables_scroll {
  border-radius: 14px;
  overflow: hidden;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  color: var(--text-primary) !important;
  border-radius: 6px;
  transition: background 0.3s;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: rgba(37, 99, 235, 0.1) !important;
  color: var(--accent) !important;
}

.wrap-cell {
  white-space: normal;
}

.document-cell {
  font-weight: 500;
  color: var(--text-primary);
}

.filename-cell {
  font-weight: 600;
  color: var(--text-primary);
}

.table-link {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.35rem;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.1);
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  word-wrap: break-word;
  transition: all 0.25s ease;
}

.table-link::before {
  content: "⇗";
  font-size: 0.85rem;
}

.table-link:hover {
  background: rgba(37, 99, 235, 0.18);
  color: #0f172a;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.2);
}

.status-pending {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  color: var(--warning);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  background: rgba(245, 158, 11, 0.15);
  letter-spacing: 0.5px;
}

.dataTables_wrapper .dataTables_length select {
  background: #fff;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 12px;
  padding-right: 2rem;
}

.dataTables_wrapper .dataTables_filter input {
  background: #fff;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 0.4rem 0.6rem 0.4rem 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='M15.5 14h-.79l-.28-.27A6 6 0 1 0 14 15.5l.27.28v.79l5 5l1.5-1.5zm-6 0a4.5 4.5 0 1 1 0-9a4.5 4.5 0 0 1 0 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
  background-size: 16px;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
  border-color: var(--accent);
}

.dataTables_wrapper .dataTables_length select option {
  background: #fff;
  color: var(--text-primary);
  padding: 0.5rem;
}

table.dataTable tbody tr:nth-child(even) {
  background: #f8fbff;
}

.dataTables_wrapper .dataTables_length label {
  color: var(--text-secondary);
  font-weight: 500;
}

.dataTables_wrapper .dataTables_filter label {
  color: var(--text-secondary);
  font-weight: 500;
}

.dataTables_wrapper .dataTables_info {
  color: rgba(71, 85, 105, 0.9);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
  opacity: 0.5;
  background: transparent !important;
}

.download-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
  min-width: 110px;
  /* prevents shrinking */
  text-align: center;
  white-space: nowrap;
}

.download-btn:hover {
  transform: translateY(-2px);
  background: var(--accent-hover);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.35);
}

.download-btn:active {
  transform: scale(0.95);
}


.table-card .dataTables_length {
  margin-bottom: 10px !important;
}


.table-card .dataTables_filter {
  margin-bottom: 10px !important;
}


.message-text {
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  line-height: 1.3;
}

.muted {
  color: #94a3b8;
}

.details-toggle {
  background: none !important;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.details-toggle:hover {
  text-decoration: underline;
}

.details-panel {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fbff;
  padding: 0.85rem;
  margin-top: 0.75rem;
}

.details-panel.full-width {
  margin: 0;
  border-radius: 0 0 12px 12px;
  border-top: none;
}

.details-open {
  border-bottom: none;
}

table.dataTable>tbody>tr.child td {
  padding: 0 !important;
  background: transparent !important;
}

.details-open+tr.child .details-panel {
  border-top: 1px solid #e2e8f0;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.details-table thead th {
  text-transform: uppercase;
  font-size: 0.75rem;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  padding-bottom: 0.6rem;
}

.details-table tbody td {
  padding: 0.55rem 0;
  border-top: 1px solid #e2e8f0;
  vertical-align: top;
  color: var(--text-primary);
}

.details-table tbody tr:first-child td {
  border-top: none;
}

/* Prevent wrapping on metadata columns */
.details-table th:nth-child(1),
.details-table td:nth-child(1),
/* Task */
.details-table th:nth-child(2),
.details-table td:nth-child(2),
/* Completed at */
.details-table th:nth-child(3),
.details-table td:nth-child(3)

/* Status */
  {
  white-space: nowrap;
  width: 1%;
  /* Shrink to fit content */
  padding-right: 1.5rem;
}

/* Description column takes remaining space */
.details-table th:nth-child(4),
.details-table td:nth-child(4) {
  width: auto;
}

.detail-line {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.detail-label {
  font-weight: 600;
  color: var(--text-primary);
}

.detail-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
}

.detail-status-success {
  background: #dcfce7;
  color: #166534;
}

.detail-status-failed {
  background: #fee2e2;
  color: #991b1b;
}

.detail-status-partial {
  background: #fef9c3;
  color: #854d0e;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-success {
  background: #dcfce7;
  color: #166534;
}

.status-partial {
  background: #fef9c3;
  color: #854d0e;
}

.status-failed {
  background: #fee2e2;
  color: #991b1b;
}

.status-unknown {
  background: #e2e8f0;
  color: #475569;
}

.details-loading,
.details-error,
.details-empty {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.details-error {
  color: #dc2626;
}

@media (max-width: 900px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .nav-actions {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 1024px) {
  .upload-card {
    width: 90%;
  }

  table.dataTable {
    width: 100% !important;
  }

  table.dataTable th,
  table.dataTable td {
    padding: 0.75rem 0.9rem;
  }
}

@media (max-width: 640px) {
  body {
    padding: 2rem 0.5rem;
  }

  .nav-actions {
    gap: 0.5rem;
  }

  .nav-btn {
    flex: 1 1 100%;
    text-align: center;
  }

  .upload-card {
    padding: 2rem 1.5rem;
  }

  .table-link {
    padding: 0.3rem 0.6rem;
    font-size: 0.85rem;
  }

  table.dataTable td {
    font-size: 0.85rem;
  }
}