:root {
  --sp-primary: #0d7e8a;
  --sp-primary-light: #e0f4f6;
  --sp-accent: #764ba2;
  --sp-bg: #f4f7f8;
  --sp-card-border: #d8eaec;
  font-size: 17px;
}

body {
  background-color: var(--sp-bg);
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  color: #2c3e50;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.container-fluid { flex: 1; }

/* ── Navbar ─────────────────────────────────────────── */
.sp-navbar {
  background: linear-gradient(135deg, #0a5e68, var(--sp-primary));
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding-top: 1rem;
  padding-bottom: 1rem;
}
.sp-navbar .navbar-brand {
  font-size: 1.5rem;
}

/* ── Cards ──────────────────────────────────────────── */
.sp-card {
  border: 1px solid var(--sp-card-border);
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  background: #fff;
}
.sp-card .card-body {
  padding: 1.4rem;
}

/* ── Two-column app layout ──────────────────────────── */
.sp-app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
  align-items: flex-start;
  max-width: 1400px;
  margin: 0 auto;
}
.sp-sidebar  { grid-column: 1; }
.sp-main-content {
  grid-column: 2;
  min-width: 0;
}

/* ── History sidebar ────────────────────────────────── */
.sp-sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
}
.sp-sidebar .card {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.sp-history-list {
  overflow-y: auto;
  flex: 1;
}
.sp-history-item {
  padding: 10px 14px;
  cursor: pointer;
  border-top: 1px solid var(--sp-card-border);
  transition: background 0.1s;
}
.sp-history-item:hover {
  background: var(--sp-primary-light);
}
.sp-history-item.active {
  background: var(--sp-primary-light);
  border-left: 3px solid var(--sp-primary);
  padding-left: 11px;
}
.sp-history-item .sp-hi-solute {
  font-weight: 600;
  font-size: 0.88rem;
  color: #2c3e50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-history-item .sp-hi-meta {
  font-size: 0.78rem;
  color: #6c757d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

/* ── Section titles ─────────────────────────────────── */
.sp-section-title {
  font-weight: 600;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sp-primary);
}

/* ── Molecule images ─────────────────────────────────── */
.sp-mol-img {
  max-width: 260px;
  max-height: 260px;
  border-radius: 6px;
  background: #fafafa;
  border: 1px solid #e0e0e0;
  padding: 4px;
}

/* ── Metric cards ───────────────────────────────────── */
.sp-metric {
  background: var(--sp-primary-light);
  border-radius: 10px;
  padding: 18px 22px;
  border-left: 5px solid var(--sp-primary);
}
.sp-metric .sp-metric-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #5a7e84;
  font-weight: 600;
}
.sp-metric .sp-metric-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: #0a5e68;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.sp-metric .sp-metric-unc {
  font-size: 0.9rem;
  color: #7a9da2;
}

/* Per-metric accent colors */
.sp-metric--logs { border-left-color: #0d7e8a; }
.sp-metric--mol  { border-left-color: #1d6fa4; background: #e8f4fb; }
.sp-metric--mol  .sp-metric-label { color: #1d6fa4; }
.sp-metric--mol  .sp-metric-value { color: #135278; }
.sp-metric--g    { border-left-color: #5a4aab; background: #eeebf8; }
.sp-metric--g    .sp-metric-label { color: #5a4aab; }
.sp-metric--g    .sp-metric-value { color: #3d2f8c; }
.sp-metric--mw   { border-left-color: #5a6e7a; background: #edf1f3; }
.sp-metric--mw   .sp-metric-label { color: #5a6e7a; }
.sp-metric--mw   .sp-metric-value { color: #3a4e58; }

/* SMILES truncation */
.sp-smiles { max-width: 100%; cursor: default; font-size: 0.9rem; }

/* Input placeholder smaller font */
.sp-input::placeholder { font-size: 0.82rem; }

/* ── Tables ─────────────────────────────────────────── */
.table thead th {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  font-weight: 600;
  border-bottom: 2px solid #dee2e6;
}
.table tbody td {
  font-size: 0.95rem;
  vertical-align: middle;
}

/* Solute group rows */
.sp-row-solute { background-color: rgba(13,126,138,0.05); }
.sp-row-solvent { background-color: rgba(118,75,162,0.05); }

/* ── Collapsible chevron ─────────────────────────────── */
.sp-chevron {
  transition: transform 0.2s;
  color: var(--sp-primary);
}
[data-bs-toggle="collapse"].collapsed .sp-chevron,
[aria-expanded="false"] .sp-chevron {
  transform: rotate(-90deg);
}

/* ── Progress bar ───────────────────────────────────── */
#progressBar {
  background-color: var(--sp-primary);
  transition: width 0.4s ease;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn-primary {
  background-color: var(--sp-primary);
  border-color: var(--sp-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: #0a5e68;
  border-color: #0a5e68;
}
.btn-outline-primary {
  color: var(--sp-primary);
  border-color: var(--sp-primary);
}
.btn-outline-primary:hover,
.btn-check:checked + .btn-outline-primary {
  background-color: var(--sp-primary);
  color: #fff;
  border-color: var(--sp-primary);
}


/* ── Autocomplete ────────────────────────────────────── */
.sp-ac-wrap {
  position: relative;
}
.sp-ac-dropdown {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  z-index: 1050;
  background: #fff;
  border: 1px solid var(--sp-card-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
}
.sp-ac-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 1rem;
  color: #2c3e50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s;
}
.sp-ac-item:hover,
.sp-ac-item.active {
  background-color: var(--sp-primary-light);
  color: var(--sp-primary);
}
.sp-ac-item .sp-ac-local {
  font-size: 0.78rem;
  color: #999;
  margin-left: 6px;
}

/* Hover preview card */
.sp-ac-preview {
  position: fixed;
  z-index: 1060;
  background: #fff;
  border: 1px solid var(--sp-card-border);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.14);
  padding: 14px 16px;
  width: 220px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.sp-ac-preview.visible {
  opacity: 1;
}
.sp-ac-preview img {
  width: 100%;
  height: 160px;
  object-fit: contain;
  border-radius: 4px;
  background: #fafafa;
}
.sp-ac-preview-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 6px;
  color: #2c3e50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-ac-preview-meta {
  font-size: 0.82rem;
  color: #6c757d;
  margin-top: 2px;
}

/* Resolved badge */
.sp-ac-badge {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--sp-primary);
  background: var(--sp-primary-light);
  border-radius: 10px;
  padding: 3px 10px;
  pointer-events: none;
  white-space: nowrap;
}

/* ── BigSolDB match button ───────────────────────────── */
.sp-db-btn {
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
  padding: 2px 7px;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.sp-db-btn--hit {
  color: #146c43;
  background: #d1e7dd;
  border-color: #a3cfbb;
}
.sp-db-btn--hit:hover {
  background: #a3cfbb;
  color: #0a4f32;
}
.sp-db-btn--miss {
  color: #bbb;
  background: transparent;
}
.sp-db-btn--miss:hover {
  color: #888;
  background: #f0f0f0;
}

/* ── History new-item flash ──────────────────────────── */
.sp-history-new {
  animation: sp-flash 0.8s ease;
}
@keyframes sp-flash {
  0%   { background-color: #d4f0d4; }
  100% { background-color: transparent; }
}

/* ── Tag input ───────────────────────────────────────── */
.sp-tag-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  padding: 6px 10px;
  border: 1px solid #ced4da;
  border-radius: 8px;
  background: #fff;
  cursor: text;
}
.sp-tag-wrap:focus-within {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 0.2rem rgba(13,126,138,0.18);
}
.sp-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--sp-primary-light);
  color: var(--sp-primary);
  border: 1px solid #b2dde2;
  border-radius: 20px;
  padding: 3px 10px 3px 12px;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}
.sp-tag--sm {
  font-size: 0.78rem;
  padding: 2px 8px 2px 10px;
}
.sp-tag-remove {
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  font-size: 1.1rem;
  color: var(--sp-primary);
  cursor: pointer;
  opacity: 0.6;
}
.sp-tag-remove:hover { opacity: 1; }
.sp-tag-input {
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  padding: 2px 4px;
  flex: 1;
  min-width: 180px;
  font-size: 1rem;
  background: transparent;
}
.sp-bsdb-sub td { background: #f8fafb; }

/* ── Image zoom overlay ──────────────────────────────── */
.sp-img-zoom {
  position: fixed;
  z-index: 1070;
  background: #fff;
  border: 1px solid var(--sp-card-border);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.22);
  padding: 14px;
  width: 600px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.sp-img-zoom.visible { opacity: 1; }
.sp-img-zoom-caption {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sp-img-zoom img {
  width: 100%;
  height: 540px;
  object-fit: contain;
  border-radius: 10px;
  background: #fafafa;
  display: block;
}

/* ── Live compound card ──────────────────────────────── */
.sp-live-card {
  background: var(--sp-primary-light);
  border: 1px solid #b2dde2;
  border-radius: 10px;
  padding: 10px 14px;
  overflow: hidden;
}
.sp-live-card .sp-live-text {
  min-width: 0;
}
.sp-live-img-wrap {
  position: relative;
  width: 68px;
  height: 68px;
  flex-shrink: 0;
}
.sp-live-img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #ddd;
  display: block;
  cursor: zoom-in;
}
.sp-live-spinner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.7);
  border-radius: 6px;
}

/* ── Solvent carousel ────────────────────────────────── */
.sp-solvent-carousel {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sp-carousel-viewport {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.sp-carousel-track {
  display: flex;
  gap: 8px;
  transition: transform 0.25s ease;
}
.sp-carousel-arrow {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--sp-card-border);
  background: #fff;
  color: var(--sp-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0;
  transition: background 0.15s;
}
.sp-carousel-arrow:hover:not(:disabled) { background: var(--sp-primary-light); }
.sp-carousel-arrow:disabled { opacity: 0.3; cursor: default; }
.sp-solvent-card {
  position: relative;
  width: 106px;
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--sp-card-border);
  border-radius: 10px;
  padding: 6px;
  text-align: center;
}
.sp-solvent-card-img {
  width: 86px;
  height: 70px;
  object-fit: contain;
  display: block;
  margin: 0 auto 3px;
  background: #fafafa;
  cursor: zoom-in;
}
.sp-solvent-card-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #2c3e50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-solvent-card-smiles {
  font-size: 0.7rem;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-solvent-card-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 70px;
}
.sp-solvent-card-remove {
  position: absolute;
  top: 3px;
  right: 5px;
  background: none;
  border: none;
  font-size: 1rem;
  line-height: 1;
  color: #bbb;
  cursor: pointer;
  padding: 0;
  z-index: 1;
}
.sp-solvent-card-remove:hover { color: #c0392b; }

/* ── log S color coding ──────────────────────────────── */
.sp-logs-high { color: #27ae60; }   /* log S > −1  (soluble)         */
.sp-logs-mid  { color: #e67e22; }   /* −3 < log S ≤ −1  (moderate)   */
.sp-logs-low  { color: #c0392b; }   /* log S ≤ −3  (poorly soluble)  */

/* ── Exp. column header ──────────────────────────────── */
.sp-th-exp { white-space: nowrap; font-size: 0.78rem; color: #6c757d; }

/* ── Sortable table headers ──────────────────────────── */
.sp-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sp-sortable:hover { background: rgba(0,0,0,0.04); }
.sp-sort-icon { font-size: 0.75em; opacity: 0.35; margin-left: 3px; }
.sp-sort-icon--active { opacity: 1; color: var(--sp-primary); }

/* ── About offcanvas links ───────────────────────────── */
.sp-link {
  color: var(--sp-primary);
  text-decoration: none;
}
.sp-link:hover { text-decoration: underline; }

/* ── Page footer ─────────────────────────────────────── */
.sp-footer {
  border-top: 1px solid var(--sp-card-border);
  background: #fff;
  padding-top: 1.2rem;
  padding-bottom: 1.2rem;
  margin-top: auto;
}
.sp-footer-logo {
  height: 56px;
  object-fit: contain;
}
.sp-footer-logo--dark {
  background: #0a5e68;
  border-radius: 8px;
  padding: 8px 14px;
}

/* ── About offcanvas logos ───────────────────────────── */
.sp-about-logo {
  height: 52px;
  object-fit: contain;
}
.sp-about-logo--dark {
  background: #0a5e68;
  border-radius: 8px;
  padding: 8px 14px;
}

/* ── Similar training solutes panel ─────────────────── */
.sp-nts-toggle {
  color: var(--sp-primary) !important;
  text-decoration: none !important;
  font-size: 0.85rem;
}
.sp-nts-toggle:hover { text-decoration: underline !important; }
.sp-nts-img {
  width: 60px;
  height: 46px;
  object-fit: contain;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  background: white;
  flex-shrink: 0;
  cursor: zoom-in;
}
.sp-nts-bar {
  height: 3px;
  background: #dee2e6;
  border-radius: 2px;
  margin: 4px 2px 2px;
  overflow: hidden;
}
.sp-nts-bar-fill { height: 100%; border-radius: 2px; }
.sp-nts-pct { font-size: 0.7rem; }
