/* Phase AF: premium SaaS polish for dashboard feedback, loading, and modal groundwork. */
#loading {
  background: var(--bg) !important;
}
#loading > div {
  min-width: 260px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--ink-soft);
  padding: 18px;
  box-shadow: var(--shadow-md);
  font-weight: 750;
}
#loading > div::before {
  content: '';
  display: block;
  height: 8px;
  width: 100%;
  border-radius: 999px;
  margin-bottom: 14px;
  background: rgba(51, 86, 238,.16);
  background-size: 220% 100%;
  animation: qf-skeleton 1.3s ease-in-out infinite;
}
.qf-toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 3000;
  display: grid;
  gap: 10px;
  max-width: min(360px, calc(100vw - 28px));
}
.qf-toast {
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--accent);
  border-radius: 15px;
  background: var(--surface);
  color: var(--ink-soft);
  box-shadow: var(--shadow-lg);
  padding: 12px 13px;
  transform: translateY(8px);
  opacity: 0;
}
.qf-toast strong {
  display: block;
  color: var(--ink);
  margin-bottom: 2px;
}
.qf-toast small {
  color: var(--muted);
}
.qf-toast.success { border-left-color: var(--success); }
.qf-toast.warn { border-left-color: var(--accent-2); }
.qf-toast.error { border-left-color: var(--error); }
.qf-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2800;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgb(3, 8, 14);
}
.qf-modal-backdrop.is-open { display: grid; }
.qf-modal-card {
  width: min(520px, 100%);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink-soft);
  box-shadow: var(--shadow-lg);
  padding: 20px;
}
.qf-modal-card h3 {
  color: var(--ink);
  margin: 0 0 8px;
  letter-spacing: -.035em;
}
.qf-modal-card p {
  color: var(--muted);
  margin: 0 0 16px;
}
.qf-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.qf-action-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.app-main button:not(.nav-item):not(.qf-mobile-nav-toggle),
.app-main .btn-primary,
.app-main .btn-danger {
  transition: all .2s ease;
}
.app-main button:not(.nav-item):not(.qf-mobile-nav-toggle):hover {
  transform: translateY(-1px);
}
.app-main button[disabled],
.app-main button.is-loading {
  opacity: .62;
  cursor: progress !important;
  transform: none !important;
}
.app-main .table tbody tr {
  transition: all .2s ease;
}
.qf-page-skeleton {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}
.qf-page-skeleton span {
  height: 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  background-size: 220% 100%;
  animation: qf-skeleton 1.3s ease-in-out infinite;
}
.qf-page-skeleton span:nth-child(1) { width: 62%; }
.qf-page-skeleton span:nth-child(2) { width: 88%; }
.qf-page-skeleton span:nth-child(3) { width: 74%; }
@keyframes qf-skeleton {
  0% { background-position: 0% 50%; }
  100% { background-position: -220% 50%; }
}
@media (max-width: 700px) {
  .qf-toast-stack { left: 14px; right: 14px; bottom: 14px; }
  .qf-modal-actions { justify-content: stretch; }
  .qf-modal-actions button { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  #loading > div::before,
  .qf-page-skeleton span,
  .qf-toast { animation: none; }
}

/* ── AI import: rate-sheet processing state ───────────────────────── */
.qf-ingest-processing {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  margin-top: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
}
.qf-ingest-spinner {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: qf-ingest-spin 0.8s linear infinite;
}
@keyframes qf-ingest-spin { to { transform: rotate(360deg); } }
.qf-ingest-processing-copy { min-width: 0; }
.qf-ingest-processing-title { color: var(--ink); font-weight: 600; font-size: 14px; }
.qf-ingest-processing-title .qf-ingest-file { color: var(--muted); font-weight: 500; }
.qf-ingest-processing-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

/* ── AI import: system auto-verification summary ──────────────────── */
.qf-autocheck {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--ink-soft);
}
.qf-autocheck-loading { color: var(--muted); }
.qf-autocheck-spin {
  flex: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: qf-ingest-spin 0.8s linear infinite;
}
.qf-autocheck-ok {
  border-color: color-mix(in srgb, var(--success) 40%, var(--border));
  background: color-mix(in srgb, var(--success) 10%, var(--surface));
}
.qf-autocheck-tick { flex: none; color: var(--success); font-weight: 700; }
.qf-autocheck-flag {
  flex-direction: column;
  border-color: color-mix(in srgb, var(--error) 55%, var(--border));
  background: color-mix(in srgb, var(--error) 12%, var(--surface));
}
.qf-autocheck-line { color: var(--ink); }
.qf-autocheck-flag .qf-autocheck-line strong { color: var(--error); }
.qf-autocheck-hint { margin-top: 4px; font-size: 12px; color: var(--ink-soft); }
.qf-autocheck-list { margin: 4px 0 0 16px; padding: 0; color: var(--ink-soft); }
.qf-autocheck-list li { margin: 4px 0; }
.qf-try-lane { margin-left: auto; }

/* ── Apply-confirm warning (flagged auto-check) ───────────────────── */
.qf-modal-body-html { margin: 4px 0 0; }
.qf-modal-warn {
  margin: 8px 0 4px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--error) 55%, var(--border));
  background: color-mix(in srgb, var(--error) 12%, var(--surface));
  font-size: 13px;
  color: var(--ink-soft);
}
.qf-modal-warn strong { color: var(--error); }
.qf-modal-ack {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 12px 0 4px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
}
.qf-modal-ack input { margin-top: 4px; flex: none; }

/* ── AI import: "Try a lane yourself" (optional) modal ────────────── */
.qf-test-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.qf-test-grid .qf-test-full { grid-column: 1 / -1; }
.qf-test-field { display: flex; flex-direction: column; gap: 4px; }
.qf-test-field label { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .02em; }
.qf-test-result {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
.qf-test-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--ink-soft);
}
.qf-test-line .qf-test-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.qf-test-total {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-weight: 700;
  color: var(--ink);
  font-size: 16px;
}
.qf-test-total .qf-test-amt { font-variant-numeric: tabular-nums; }
.qf-modal-card.qf-test-card { width: min(560px, 100%); text-align: left; }
.qf-modal-card.qf-test-card .qf-modal-actions { justify-content: space-between; margin-top: 16px; }
@media (max-width: 560px) {
  .qf-test-grid { grid-template-columns: 1fr; }
}

/* ── AI import: staged microcopy (cross-fade the processing subtitle) ── */
.qf-ingest-processing-sub {
  transition: all .2s ease;
}
.qf-ingest-processing-sub.is-swapping {
  opacity: 0;
  transform: translateY(-3px);
}

/* ── AI import: skeleton preview of the parsed rate cards ────────────── */
/* Reuses the qf-skeleton shimmer keyframe. Token-mixed base stays visible
   in both light and dark themes (no literal colors). */
.qf-ingest-skeleton {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}
.qf-ingest-skeleton-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}
.qf-skel-line {
  display: block;
  height: 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink);
  background-size: 220% 100%;
  animation: qf-skeleton 1.3s ease-in-out infinite;
}
.qf-skel-title { width: 46%; height: 14px; }
.qf-skel-meta { width: 72%; }
.qf-ingest-skeleton-row:nth-child(2) .qf-skel-line { animation-delay: .15s; }
.qf-ingest-skeleton-row:nth-child(3) .qf-skel-line { animation-delay: .3s; }

/* ── AI import: staged progress bar (rate-engine build indicator) ────── */
/* A thin token-colored track whose fill advances per processing stage
   (driven from app.js startStages) with a glossy sheen sweeping across it so
   the wait reads as a live multi-stage engine. Caps at 94% until the parse
   truly completes. */
.qf-ingest-progress {
  position: relative;
  height: 6px;
  margin-top: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}
.qf-ingest-progress-fill {
  position: relative;
  display: block;
  width: 12%;
  height: 100%;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent);
  transition: all .3s ease;
}.qf-reveal-row {
  opacity: 0;
}

/* ── AI import: self-drawing confidence checkmark ───────────────────── */
.qf-check-draw {
  flex: none;
  transform: translateY(1px); /* optical align to text baseline (not a spacing prop) */
  color: var(--success);
}
.qf-check-draw .qf-check-circle { opacity: .4; }
.qf-check-draw .qf-check-path { stroke-dasharray: 24; stroke-dashoffset: 0; }
.qf-check-draw.is-animating .qf-check-circle {
  stroke-dasharray: 64;
  stroke-dashoffset: 64;
}
.qf-check-draw.is-animating .qf-check-path {
  stroke-dashoffset: 24;
}

/* ── AI import: Recent-uploads table — no clip/wrap at 375px ─────────── */
.qf-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.qf-table-scroll .table th,
.qf-table-scroll .table td { white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .qf-skel-line,
  .qf-reveal-in,
  .qf-reveal-row,
  .qf-check-draw.is-animating .qf-check-circle,
  .qf-check-draw.is-animating .qf-check-path { animation: none !important; }
  .qf-reveal-in,
  .qf-reveal-row { opacity: 1 !important; transform: none !important; }
  .qf-ingest-processing-sub { transition: none !important; }
  .qf-ingest-progress-fill { transition: none !important; }
  .qf-ingest-progress-fill::after { animation: none !important; }
  .qf-check-draw.is-animating .qf-check-circle { stroke-dashoffset: 0 !important; }
  .qf-check-draw.is-animating .qf-check-path { stroke-dashoffset: 0 !important; }
}
