/* BUTTONS, PANELS, TABLES, BADGES, FORMS, MODALS, FILE VIEWER, CASE DETAIL */
.btn {
  font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 13.5px;
  padding: 10px 18px; border-radius: 999px; border: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: transform .15s ease, opacity .15s ease, background .15s ease, border-color .15s ease;
  cursor: pointer;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--ink); color: #fff; position: relative; overflow: hidden; isolation: isolate; }
.btn-primary::before { content: ''; position: absolute; inset: 0; background: linear-gradient(100deg, var(--navy), var(--violet)); transform: translateX(-101%); transition: transform .4s cubic-bezier(.2,.9,.3,1); z-index: -1; }
.btn-primary:hover::before { transform: translateX(0); }
.btn-ghost { background: #fff; color: var(--ink); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--slate); }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
.btn-danger { background: #F0EEF7; color: var(--ink); border: 1px solid var(--border); }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 8px; background: #fff; border: 1.5px solid var(--border); color: var(--slate); }
.btn-icon:hover { border-color: var(--violetlt); color: var(--violet); }

.stat-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 18px 18px; box-shadow: var(--shadow); transition: background 0.3s, border-color 0.3s;
}
.stat-card .lbl { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; color: var(--text-secondary); letter-spacing: .06em; text-transform: uppercase; margin-bottom: 6px; }
.stat-card .val { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 26px; color: var(--text-primary); }
.stat-card .sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.stat-card.accent-violet .val { color: var(--violet); }
.stat-card.accent-warning .val { color: var(--violet-600); }
.stat-card.accent-danger .val { color: var(--ink); }
.stat-card.accent-success .val { color: var(--violet); }
.stat-card.accent-info .val { color: var(--violetlt); }

.panel {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); margin-bottom: 20px; transition: background 0.3s, border-color 0.3s;
}
.panel-head { padding: 16px 22px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-title { font-size: 15px; font-weight: 800; color: var(--text-primary); }
.panel-body { padding: 18px 22px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-input {
  display: flex; align-items: center; gap: 8px; background: var(--paper); border: 1.5px solid var(--border);
  border-radius: 999px; padding: 8px 14px; min-width: 220px;
}
.search-input input { border: none; background: none; outline: none; font-size: 13.5px; width: 100%; color: var(--ink); }
.search-input svg { color: var(--slate-lt); flex-shrink: 0; }
.filter-select {
  border: 1.5px solid var(--border); border-radius: 999px; padding: 8px 30px 8px 14px; font-size: 13px;
  background: #fff; color: var(--ink); outline: none; cursor: pointer;
}

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table thead th {
  text-align: left; padding: 10px 14px; font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}
.data-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.data-table tbody tr { transition: background .12s ease; }
.data-table tbody tr:hover { background: var(--paper); }
.data-table tbody tr:last-child td { border-bottom: none; }
.cell-primary { font-weight: 700; color: var(--text-primary); }
.cell-sub { font-size: 11.5px; color: var(--text-secondary); margin-top: 2px; }
.cell-mono { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--text-secondary); }
.empty-row { text-align: center; padding: 50px 20px; color: var(--text-secondary); font-size: 13.5px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  text-transform: none;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; background: currentColor; }

/* All badges now use brand-only palette */
.badge-new           { background: #EDE9FE; color: #5B21B6; }
.badge-progress      { background: #DDD6FE; color: #5B21B6; }
.badge-discrepancy   { background: #0B1230; color: #FFFFFF; }
.badge-completed     { background: #7C3AED; color: #FFFFFF; }
.badge-hold          { background: #EFEEF9; color: #545A78; }
.badge-in-qa         { background: #FFFFFF; color: #6D28D9; border: 1.5px solid #7C3AED; }
.badge-approved      { background: #7C3AED; color: #FFFFFF; }
.badge-pending-consent  { background: #DDD6FE; color: #5B21B6; }
.badge-consent-received { background: #EDE9FE; color: #5B21B6; }
.badge-failed        { background: #0B1230; color: #FFFFFF; }

.badge-priority-urgent   { background: #0B1230; color: #FFFFFF; }
.badge-priority-standard { background: #EFEEF9; color: #545A78; }

.badge-green {
  background: #7C3AED; color: #FFFFFF;
  padding: 3px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase;
}

/* FORM PRIMITIVES */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid.single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.span-2 { grid-column: 1 / -1; }
.field label { font-family: 'IBM Plex Mono', monospace; font-size: 10.5px; letter-spacing: .06em; color: var(--slate); text-transform: uppercase; display: flex; align-items: center; gap: 5px; }
.field label .req { color: var(--ink); }
.field-input, .field select, .field textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: 14px; color: var(--ink); background: #fff; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
  font-family: 'Inter', sans-serif;
}
.field-input:focus, .field select:focus, .field textarea:focus { border-color: var(--violet); box-shadow: 0 0 0 3.5px rgba(124,58,237,0.12); }
.field-msg { font-size: 11.5px; color: var(--ink); min-height: 14px; }
.field-msg.error { color: var(--ink); }
.field-msg.success { color: var(--violet); }
textarea { resize: vertical; min-height: 70px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.checkbox-tile {
  display: flex; align-items: center; gap: 9px; padding: 11px 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; background: var(--paper);
  transition: border-color .18s ease, background .18s ease;
}
.checkbox-tile input { accent-color: var(--violet); width: 16px; height: 16px; }
.checkbox-tile:hover { border-color: var(--violetlt); }
.checkbox-tile:has(input:checked) { border-color: var(--violet); background: rgba(124,58,237,0.06); }
.radio-pill-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill { display: flex; align-items: center; gap: 7px; padding: 9px 15px; border: 1.5px solid var(--border); border-radius: 999px; cursor: pointer; font-size: 13px; font-weight: 600; transition: border-color .18s ease, background .18s ease; }
.radio-pill input { accent-color: var(--violet); }
.radio-pill.is-active, .radio-pill:has(input:checked) { border-color: var(--violet); background: rgba(124,58,237,0.06); }

/* MODALS */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,18,48,0.55); backdrop-filter: blur(2px);
  display: none; align-items: flex-start; justify-content: center; z-index: 200; padding: 36px 20px; overflow-y: auto;
}
.modal-overlay.is-active { display: flex; }
.modal-card {
  background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 760px;
  box-shadow: var(--shadow-lg); animation: modal-in .22s cubic-bezier(.2,.9,.3,1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-head { padding: 20px 26px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 800; }
.modal-close { background: none; border: none; color: var(--slate); width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.modal-close:hover { background: var(--paper); color: var(--ink); }
.modal-body { padding: 22px 26px; max-height: 68vh; overflow-y: auto; }
.modal-foot { padding: 16px 26px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 10px; }

/* NEW MODAL (for index.html) */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.is-active { display: flex; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 48, 0.55);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 48px rgba(11, 18, 48, 0.2);
  animation: modal-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 1;
  border-radius: 16px 16px 0 0;
}
.modal-header h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--slate-lt);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}
.modal-close:hover {
  background: var(--paper);
  color: var(--ink);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-soft);
  position: sticky;
  bottom: 0;
  background: #ffffff;
  border-radius: 0 0 16px 16px;
}
.hidden { display: none !important; }

/* FILE VIEWER (legacy modal — kept for compatibility) */
.file-viewer-modal .modal-card { max-width: 75vw; max-height: 75vh; display: flex; flex-direction: column; }
.file-viewer-modal .modal-body { overflow: auto; text-align: center; position: relative; display: flex; align-items: center; justify-content: center; background: #f0f0f0; padding: 0; }
.file-viewer-modal .modal-body img { max-width: 100%; max-height: 100%; object-fit: contain; transition: transform 0.3s ease; transform-origin: center; user-select: none; pointer-events: none; }
.file-viewer-controls { position: absolute; top: 10px; right: 10px; display: flex; gap: 8px; z-index: 10; }
.zoom-badge { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.8); font-size: 12px; background: rgba(0,0,0,0.5); padding: 4px 12px; border-radius: 12px; }

/* ============================================================
   INLINE FILE VIEWER (click filename to maximize inline)
   ============================================================ */
.file-block {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color .15s ease;
}
.file-block.is-open { border-color: var(--violetlt); }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
}
.file-row:hover { background: var(--paperdim); }
.file-row .file-icon {
  width: 30px; height: 30px; border-radius: 6px; background: var(--paperdim);
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.file-row .file-icon img { width: 100%; height: 100%; object-fit: cover; }
.file-row .file-name {
  flex: 1; min-width: 0; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: var(--ink);
}
.file-row .file-meta { font-size: 11px; color: var(--slate); font-family: 'IBM Plex Mono', monospace; flex-shrink: 0; }
.file-row .file-toggle {
  flex-shrink: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 11px; font-weight: 700; color: var(--slate);
  display: inline-flex; align-items: center; gap: 4px;
}
.file-block.is-open .file-row .file-toggle { color: var(--violet); border-color: var(--violetlt); }
.file-block.is-open .file-row .file-toggle .toggle-label::before { content: 'Minimize'; }
.file-block.is-open .file-row .file-toggle .toggle-label-text { display: none; }

.file-stage {
  display: none;
  border-top: 1px solid var(--border-soft);
  background: #f0f0f0;
  position: relative;
  padding: 0;
}
.file-block.is-open .file-stage { display: block; }
.file-stage-inner {
  position: relative;
  overflow: auto;
  max-height: 78vh;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}
.file-stage img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  transition: transform .2s ease;
  transform-origin: center center;
  user-select: none;
  display: block;
}
.file-stage iframe {
  width: 100%;
  height: 78vh;
  border: none;
  background: #fff;
}
.file-stage .zoom-bar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border-soft);
  z-index: 5;
}
.file-stage .zoom-bar button {
  background: #fff; border: 1px solid var(--border); border-radius: 6px;
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--slate); cursor: pointer;
}
.file-stage .zoom-bar button:hover { border-color: var(--violetlt); color: var(--violet); }
.file-stage .zoom-bar .zoom-label {
  display: inline-flex; align-items: center; padding: 0 10px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--slate);
}
.file-stage .no-preview {
  padding: 40px 20px; text-align: center; color: var(--slate); font-size: 13px;
}
.file-stage .no-preview a { color: var(--violet); font-weight: 700; text-decoration: underline; }

/* TOAST */
.toast {
  position: fixed; bottom: 26px; right: 26px; z-index: 300; background: var(--ink); color: #fff;
  padding: 13px 20px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px; transform: translateY(20px); opacity: 0; transition: transform .25s ease, opacity .25s ease;
  pointer-events: none;
}
.toast.is-active { transform: translateY(0); opacity: 1; }
.toast svg { color: #fff; flex-shrink: 0; }

.toast.toast-success { background: var(--violet); color: #fff; }
.toast.toast-success svg { color: #fff; }
.toast.toast-error   { background: var(--ink); color: #fff; }
.toast.toast-error svg { color: #fff; }
.toast.toast-warning { background: var(--violet-600); color: #fff; }
.toast.toast-warning svg { color: #fff; }

/* Upload Area for API Verifications */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--paper);
}
.upload-area:hover { border-color: var(--violet); background: rgba(124,58,237,0.04); }
.upload-area.dragover { border-color: var(--violet); background: rgba(124,58,237,0.08); }
.upload-area svg { width: 40px; height: 40px; color: var(--slate-lt); margin-bottom: 12px; }
.upload-area p { margin: 0; font-size: 14px; color: var(--slate); }
.upload-area .upload-hint { display: block; margin-top: 8px; font-size: 12px; color: var(--slate-lt); }

/* Page header (used by qc.js, systemConfig.js) */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary, var(--ink));
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary, var(--slate));
  margin: 0;
  line-height: 1.5;
}

/* LOADING OVERLAY */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(11,18,48,0.55); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; flex-direction: column; gap: 14px; z-index: 400;
}
.loading-overlay.is-active { display: flex; }
.loading-spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.25); border-top-color: #fff;
  animation: spinner 0.8s linear infinite;
}
@keyframes spinner { to { transform: rotate(360deg); } }
.loading-message { color: #fff; font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }

/* FILE VIEWER MODAL SIZING */
.file-viewer-modal .modal-content {
  max-width: 78vw; max-height: 88vh; display: flex; flex-direction: column;
}
.file-viewer-modal .modal-body {
  position: relative; padding: 0; background: #f0f0f0;
  display: flex; align-items: center; justify-content: center;
  min-height: 340px; max-height: 75vh; overflow: auto;
}
.file-viewer-modal #fileViewerImage {
  max-width: 100%; max-height: 75vh; object-fit: contain;
  transition: transform 0.2s ease; transform-origin: center center;
  user-select: none; display: block;
}
.file-viewer-modal .file-viewer-controls { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; z-index: 10; }
.file-viewer-modal .zoom-badge {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.9); font-size: 11px; font-family: 'IBM Plex Mono', monospace;
  background: rgba(0,0,0,0.55); padding: 4px 12px; border-radius: 12px; pointer-events: none;
}

/* SIDEBAR / TOPBAR HIDDEN UTILITIES */
.sidebar-link.hidden { display: none !important; }
#btnBulkUpload.hidden { display: none !important; }
#navQC.hidden { display: none !important; }

/* BULK UPLOAD MODAL STYLES */
.bulk-drop-zone {
  border: 2px dashed var(--border, rgba(19,27,69,0.12));
  border-radius: var(--radius-md, 10px);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--paper, #F7F7FB);
}
.bulk-drop-zone:hover, .bulk-drop-zone.is-dragover { border-color: var(--violet); background: rgba(124,58,237,0.04); }
.bulk-drop-zone svg { width: 38px; height: 38px; color: var(--slate-lt); margin-bottom: 10px; }
.bulk-drop-zone p { margin: 0; font-size: 13.5px; color: var(--slate); }
.bulk-drop-zone .bulk-hint { display: block; margin-top: 6px; font-size: 11.5px; color: var(--slate-lt); }
.bulk-file-pill {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; margin-top: 12px; font-size: 13px;
}
.bulk-file-pill .bulk-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.bulk-file-pill .bulk-size { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--slate); }
.bulk-preview-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 12px; }
.bulk-preview-table th, .bulk-preview-table td {
  text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
}
.bulk-preview-table th {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-secondary);
}
.bulk-preview-wrap { max-height: 240px; overflow-y: auto; border: 1px solid var(--border-soft); border-radius: 8px; margin-top: 12px; }

/* QC PAGE */
.qc-filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.qc-tab {
  padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--border);
  background: #fff; font-size: 12.5px; font-weight: 600; color: var(--slate);
  cursor: pointer; transition: all 0.15s ease;
}
.qc-tab.is-active { border-color: var(--violet); background: rgba(124,58,237,0.08); color: var(--violet); }
.qc-tab:hover:not(.is-active) { border-color: var(--slate-lt); }

/* MISC HELPERS */
.text-muted { color: var(--text-secondary, var(--slate)); }
.text-mono { font-family: 'IBM Plex Mono', monospace; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* EMERGENCY MODAL VISIBILITY FIX */
.modal.is-active {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
.modal:not(.is-active) { display: none !important; }
#createCaseModal.modal.is-active,
#addClientModal.modal.is-active,
#addTeamModal.modal.is-active,
#resetPasswordModal.modal.is-active,
#fileViewerModal.modal.is-active,
#bulkUploadModal.modal.is-active { display: flex !important; }

/* Responsive */
@media (max-width: 768px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .checkbox-grid { grid-template-columns: 1fr 1fr; }
  .modal-content { max-width: 100%; margin: 0 10px; }
}
