/* ============================================================
   SP Backend — Modern Dashboard Styles
   Only loaded for authenticated service-provider pages.
   ============================================================ */

/* ---------- Design tokens (CSS custom properties) ---------- */
:root {
  --sp-primary: #37b34a;
  --sp-primary-dark: #2e9a3f;
  --sp-primary-light: #e8f5ea;

  --sp-bg: #f4f6f9;
  --sp-surface: #ffffff;
  --sp-border: #e2e6ed;
  --sp-border-light: #f0f2f5;

  --sp-text: #1e2a3a;
  --sp-text-muted: #6b7a8d;
  --sp-text-light: #9aa5b4;

  --sp-success: #22c55e;
  --sp-warning: #f59e0b;
  --sp-danger: #ef4444;
  --sp-info: #3b82f6;

  --sp-radius: 12px;
  --sp-radius-sm: 8px;
  --sp-radius-lg: 16px;
  --sp-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --sp-shadow-md: 0 4px 12px rgba(0,0,0,.07);
  --sp-shadow-lg: 0 8px 24px rgba(0,0,0,.09);

  --sp-font: "Rubik", system-ui, -apple-system, sans-serif;
  --sp-nav-width: 260px;
  --sp-topbar-height: 60px;
}

/* ---------- Global resets for SP pages --------------------- */
body.sp-backend {
  background-color: var(--sp-bg);
  font-family: var(--sp-font);
  color: var(--sp-text);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top bar --------------------------------------- */
.sp-topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--sp-topbar-height);
  background: var(--sp-surface);
  border-bottom: 1px solid var(--sp-border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  box-shadow: var(--sp-shadow);
}

.sp-topbar .sp-brand {
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  color: var(--sp-text);
  text-transform: uppercase;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sp-topbar .sp-brand img {
  height: 28px;
  width: auto;
}

.sp-topbar-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.sp-menu-toggle {
  background: none;
  border: none;
  font-size: 1.35rem;
  color: var(--sp-text);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: var(--sp-radius-sm);
  transition: background .15s;
}
.sp-menu-toggle:hover { background: var(--sp-border-light); }

/* ---------- Sidebar / offcanvas nav ---------------------- */
.sp-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sp-nav-width);
  background: var(--sp-surface);
  border-right: 1px solid var(--sp-border);
  z-index: 1040;
  transform: translateX(-100%);
  transition: transform .25s ease;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.sp-sidebar.open {
  transform: translateX(0);
}
.sp-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  z-index: 1039;
}
.sp-sidebar-backdrop.show { display: block; }

.sp-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--sp-border);
}
.sp-sidebar-header .sp-brand {
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: var(--sp-text);
  text-transform: uppercase;
}
.sp-sidebar-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--sp-text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.sp-nav {
  list-style: none;
  padding: .75rem 0;
  margin: 0;
  flex: 1;
}
.sp-nav li a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.25rem;
  color: var(--sp-text-muted);
  text-decoration: none;
  font-size: .925rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
}
.sp-nav li a:hover {
  background: var(--sp-bg);
  color: var(--sp-text);
}
.sp-nav li a.active {
  color: var(--sp-primary);
  background: var(--sp-primary-light);
  font-weight: 600;
}
.sp-nav li a i {
  width: 20px;
  text-align: center;
  font-size: .95rem;
}
.sp-nav-divider {
  height: 1px;
  background: var(--sp-border);
  margin: .5rem 1.25rem;
}

/* Username / footer inside sidebar */
.sp-sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--sp-border);
  font-size: .85rem;
  color: var(--sp-text-muted);
}

/* ---------- Desktop: show sidebar, hide topbar ------------ */
@media (min-width: 992px) {
  .sp-sidebar {
    transform: translateX(0);
    top: 0;
  }
  .sp-sidebar-backdrop { display: none !important; }
  .sp-sidebar-close { display: none; }

  .sp-topbar {
    display: none;
  }
  .sp-main {
    margin-left: var(--sp-nav-width);
  }
}

/* ---------- Main content area ----------------------------- */
.sp-main {
  padding: 1.25rem 1rem 2rem;
  max-width: 1200px;
}
@media (min-width: 992px) {
  .sp-main {
    padding: 1.5rem 2rem 3rem;
  }
}

/* ---------- Page header ----------------------------------- */
.sp-page-header {
  margin-bottom: 1.25rem;
}
.sp-page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: var(--sp-text);
}
@media (min-width: 768px) {
  .sp-page-header h1 { font-size: 1.65rem; }
}
.sp-page-header p {
  color: var(--sp-text-muted);
  margin: .25rem 0 0;
  font-size: .9rem;
}

/* ---------- Cards ----------------------------------------- */
.sp-card {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.sp-card-lg {
  padding: 1.5rem;
}
.sp-card-flush {
  padding: 0;
}
.sp-card-header {
  font-size: 1rem;
  font-weight: 600;
  color: var(--sp-text);
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sp-card-header i { color: var(--sp-text-muted); }

/* ---------- Stat widgets ---------------------------------- */
.sp-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .75rem;
}
@media (min-width: 768px) {
  .sp-stats-grid { grid-template-columns: repeat(4, 1fr); }
}

.sp-stat {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 1rem;
  text-align: center;
  box-shadow: var(--sp-shadow);
}
.sp-stat-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--sp-text-muted);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.sp-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--sp-text);
  line-height: 1.2;
}
.sp-stat-sub {
  font-size: .75rem;
  color: var(--sp-text-light);
  margin-top: .35rem;
}

/* ---------- Bid bar (dashboard top) ----------------------- */
.sp-bid-bar {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  box-shadow: var(--sp-shadow);
  margin-bottom: 1rem;
}
.sp-bid-bar p {
  margin: 0;
  font-size: .925rem;
  color: var(--sp-text);
}
.sp-bid-bar select {
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  padding: .4rem 1.5rem .4rem .6rem;
  font-size: .9rem;
  font-weight: 500;
  background: var(--sp-bg);
  color: var(--sp-text);
  cursor: pointer;
  transition: border-color .15s;
  max-width: none;
}
.sp-bid-bar select:focus {
  border-color: var(--sp-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(55,179,74,.15);
}
.sp-bid-bar select.border-danger {
  border-color: var(--sp-danger);
}

/* ---------- Custom bid dropdown -------------------------- */
.bid-dropdown {
  display: inline-block;
  position: relative;
  vertical-align: middle;
}
.bid-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  padding: .4rem 1rem .4rem .6rem;
  background: var(--sp-bg, #fff);
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--sp-text);
  transition: border-color .15s;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
.bid-dropdown-trigger:hover,
.bid-dropdown.open .bid-dropdown-trigger {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px rgba(55,179,74,.15);
}
.bid-dropdown-caret {
  margin-left: 6px;
  font-size: .65em;
  opacity: .6;
}
.bid-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1050;
  min-width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  box-shadow: 0 4px 14px rgba(0,0,0,.13);
  margin-top: 3px;
  padding: 4px 0;
  display: none;
  -webkit-overflow-scrolling: touch;
}
.bid-dropdown.open .bid-dropdown-menu {
  display: block;
}
.bid-dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 12px;
  cursor: pointer;
  font-size: .85rem;
  white-space: nowrap;
  gap: 16px;
  color: var(--sp-text);
}
.bid-dropdown-item:hover {
  background: #f0f7f1;
}
.bid-dropdown-item.bdi-selected {
  background: #e6f4ea;
  font-weight: 600;
}
.bid-dropdown-item .bdi-price {
  flex-shrink: 0;
}
.bid-dropdown-item .bdi-delta {
  font-size: .8rem;
  font-weight: 500;
}
.bdi-delta-pos  { color: #1a8c3a; }
.bdi-delta-neg  { color: #c0392b; }
.bdi-delta-zero { color: #999; }

/* ---------- Credit indicator ------------------------------ */
.sp-credit {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .95rem;
  font-weight: 600;
}
.sp-credit-ok { color: var(--sp-success); }
.sp-credit-low { color: var(--sp-warning); }
.sp-credit-danger { color: var(--sp-danger); }

/* ---------- Tables ---------------------------------------- */
.sp-table-wrap {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  overflow: hidden;
  box-shadow: var(--sp-shadow);
}
.sp-table-wrap .table,
.sp-card-flush .table { margin-bottom: 0; }

.sp-table-wrap .table thead th,
.sp-card-flush .table thead th,
body.sp-backend .table thead th {
  background: var(--sp-bg);
  border-bottom: 2px solid var(--sp-border);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--sp-text-muted);
  padding: .65rem .75rem;
  white-space: nowrap;
}
.sp-table-wrap .table tbody td,
.sp-card-flush .table tbody td,
body.sp-backend .table tbody td {
  padding: .65rem .75rem;
  vertical-align: middle;
  font-size: .9rem;
  border-color: var(--sp-border-light);
}
body.sp-backend .table-clickable tbody tr {
  cursor: pointer;
  transition: background .12s;
}
body.sp-backend .table-clickable tbody tr:hover {
  background: var(--sp-primary-light);
}

/* Scrollable table body */
.sp-table-scroll tbody {
  display: block;
  max-height: 500px;
  overflow-y: auto;
}
.sp-table-scroll thead,
.sp-table-scroll tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}
.sp-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

/* ---------- Forms ----------------------------------------- */
.sp-form label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--sp-text);
  display: block;
  margin-bottom: .35rem;
}
.sp-form input[type="text"],
.sp-form input[type="tel"],
.sp-form input[type="email"],
.sp-form input[type="password"],
.sp-form input[type="number"],
.sp-form select,
.sp-form textarea {
  width: 100%;
  padding: .55rem .75rem;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  font-size: .9rem;
  font-family: var(--sp-font);
  color: var(--sp-text);
  background: var(--sp-surface);
  transition: border-color .15s, box-shadow .15s;
  margin-bottom: .75rem;
}
.sp-form input:focus,
.sp-form select:focus,
.sp-form textarea:focus {
  border-color: var(--sp-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(55,179,74,.12);
}
.sp-form textarea {
  resize: vertical;
  min-height: 80px;
}
.sp-form .form-hint {
  font-size: .8rem;
  color: var(--sp-text-muted);
  margin-top: -.5rem;
  margin-bottom: .75rem;
}

/* ---------- Buttons --------------------------------------- */
body.sp-backend .btn {
  font-weight: 500;
  font-size: .9rem;
  border-radius: var(--sp-radius-sm);
  padding: .5rem 1.1rem;
  transition: all .15s ease;
}
body.sp-backend .btn-primary {
  background: var(--sp-primary);
  border-color: var(--sp-primary);
  color: #fff;
}
body.sp-backend .btn-primary:hover,
body.sp-backend .btn-primary:focus {
  background: var(--sp-primary-dark);
  border-color: var(--sp-primary-dark);
  box-shadow: 0 2px 8px rgba(55,179,74,.25);
}
body.sp-backend .btn-outline-dark {
  border-color: var(--sp-border);
  color: var(--sp-text);
}
body.sp-backend .btn-outline-dark:hover {
  background: var(--sp-bg);
  border-color: var(--sp-text-muted);
}
body.sp-backend .btn-back {
  color: var(--sp-text-muted);
  text-decoration: none;
  font-size: .875rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem 0;
  transition: color .15s;
}
body.sp-backend .btn-back:hover { color: var(--sp-text); }

/* ---------- Search bar ------------------------------------ */
.sp-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
}
.sp-search input {
  flex: 1;
  max-width: 280px;
  padding: .45rem .75rem;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  font-size: .875rem;
  transition: border-color .15s;
}
.sp-search input:focus {
  border-color: var(--sp-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(55,179,74,.12);
}
.sp-search .btn {
  padding: .45rem .75rem;
}

/* ---------- Period filter pills --------------------------- */
.sp-period-filter {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
.sp-period-filter label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--sp-text-muted);
  white-space: nowrap;
}
.sp-period-filter select {
  padding: .35rem .6rem;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  font-size: .82rem;
  background: var(--sp-surface);
  color: var(--sp-text);
  cursor: pointer;
}
.sp-period-filter select:focus {
  border-color: var(--sp-primary);
  outline: none;
}

/* ---------- Lead status buttons (lead page) --------------- */
.sp-status-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .55rem 1rem;
  border-radius: var(--sp-radius-sm);
  font-size: .875rem;
  font-weight: 500;
  border: 2px solid var(--sp-border);
  background: var(--sp-surface);
  color: var(--sp-text-muted);
  cursor: pointer;
  transition: all .2s ease;
  text-decoration: none;
}
.sp-status-btn:hover { border-color: var(--sp-text-light); }

.sp-status-btn-success:hover,
.sp-status-btn-success.selected {
  background: var(--sp-success);
  border-color: var(--sp-success);
  color: #fff;
}
.sp-status-btn-warning:hover,
.sp-status-btn-warning.selected {
  background: var(--sp-warning);
  border-color: var(--sp-warning);
  color: #fff;
}
.sp-status-btn-danger:hover,
.sp-status-btn-danger.selected {
  background: var(--sp-danger);
  border-color: var(--sp-danger);
  color: #fff;
}

/* ---------- Competition table ----------------------------- */
.sp-competition-table {
  font-size: .875rem;
}
.sp-competition-table th {
  font-weight: 600;
  color: var(--sp-text-muted);
  font-size: .78rem;
  text-transform: uppercase;
}

/* ---------- Invoice --------------------------------------- */
.sp-invoice-wrap {
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  padding: 1.5rem;
  box-shadow: var(--sp-shadow);
}

/* ---------- Pagination ------------------------------------ */
body.sp-backend .pagination .page-link {
  border-radius: var(--sp-radius-sm);
  border: 1px solid var(--sp-border);
  color: var(--sp-text);
  margin: 0 2px;
  font-size: .85rem;
  padding: .35rem .65rem;
}
body.sp-backend .pagination .page-item.active .page-link {
  background: var(--sp-primary);
  border-color: var(--sp-primary);
  color: #fff;
}

/* ---------- Prediction widget ----------------------------- */
#prediction-widget p {
  margin-bottom: 0;
}
.pw-pulse-dot {
  font-size: 0.5em;
  margin-right: 0.3rem;
  vertical-align: middle;
  --fa-beat-fade-scale: 1.1;
  --fa-animation-duration: 2.5s;
}
.pw-pulse-dot--green { color: #22c55e; }
.pw-pulse-dot--yellow { color: #d4a017; }
.pw-pulse-dot--red { color: var(--sp-danger); }

/* ---------- WhatsApp preview (account settings) ----------- */
.sp-wa-preview {
  background: #efeae2;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-lg);
  padding: 1rem;
  min-height: 200px;
  display: flex;
  align-items: flex-end;
  position: relative;
  overflow: hidden;
}
.sp-wa-preview .statusbar {
  position: absolute;
  top: 8px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--sp-text-muted);
}
.sp-wa-preview .bubble {
  background: #dcf8c6;
  color: #111b21;
  border-radius: 12px 12px 4px 12px;
  padding: .65rem .8rem;
  max-width: 320px;
  font-size: .85rem;
  box-shadow: 0 1px 0 rgba(0,0,0,.06);
  word-wrap: break-word;
}
.sp-wa-preview .timestamp {
  display: block;
  margin-top: .35rem;
  font-size: .7rem;
  color: #667781;
  text-align: right;
}

/* ---------- Stripe card form (payment) -------------------- */
.sp-stripe-card {
  max-width: 420px;
  padding: 1.25rem;
  background: var(--sp-surface);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius);
  box-shadow: var(--sp-shadow);
}
#card-element {
  padding: .65rem .85rem;
  background: var(--sp-bg);
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  transition: border-color .2s, box-shadow .2s;
}
#card-element.StripeElement--focus {
  border-color: var(--sp-primary);
  box-shadow: 0 0 0 3px rgba(55,179,74,.15);
}
#card-element.StripeElement--invalid {
  border-color: var(--sp-danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,.15);
}

/* ---------- Amount buttons (payment) ---------------------- */
.sp-amount-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: .5rem 1rem;
  border: 2px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  background: var(--sp-surface);
  color: var(--sp-text);
  font-weight: 600;
  font-size: .9rem;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.sp-amount-btn:hover {
  border-color: var(--sp-primary);
  color: var(--sp-primary);
}
.sp-amount-btn.disabled,
.sp-amount-btn.active {
  background: var(--sp-primary);
  border-color: var(--sp-primary);
  color: #fff;
}

/* ---------- Onboarding progress bar ----------------------- */
.sp-progress-bar {
  height: 6px;
  background: var(--sp-border);
  border-radius: 3px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.sp-progress-bar-fill {
  height: 100%;
  background: var(--sp-primary);
  border-radius: 3px;
  transition: width .3s ease;
}

/* ---------- Badge ----------------------------------------- */
.sp-badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.sp-badge-success { background: var(--sp-primary-light); color: var(--sp-primary-dark); }
.sp-badge-warning { background: #fef3c7; color: #92400e; }
.sp-badge-danger { background: #fee2e2; color: #991b1b; }
.sp-badge-muted { background: var(--sp-bg); color: var(--sp-text-muted); }

/* ---------- Empty state ----------------------------------- */
.sp-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--sp-text-muted);
}
.sp-empty i {
  font-size: 2rem;
  margin-bottom: .75rem;
  display: block;
  opacity: .4;
}

/* ---------- Bid form inline currency input ----------------- */
.sp-bid-bar .currency-container {
  position: relative;
  display: inline-block;
}
.sp-bid-bar .currency-symbol {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: .85rem;
  color: var(--sp-text-muted);
  pointer-events: none;
}
.sp-bid-bar .currency-container input {
  border: 1px solid var(--sp-border);
  background: var(--sp-bg);
  border-radius: var(--sp-radius-sm);
  padding: .35rem .5rem .35rem 1.3rem;
  max-width: 80px;
  font-size: .9rem;
  font-weight: 500;
}

/* ---------- Loader animation (bid form) ------------------- */
.sp-loader {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  position: relative;
  border: 2px solid var(--sp-info);
  display: inline-block;
  vertical-align: middle;
}
.sp-loader .wave {
  position: absolute;
  width: 400%;
  height: 100%;
  background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 100 50" xmlns="http://www.w3.org/2000/svg"><path fill="%233b82f6" d="M0 30 Q 25 10, 50 30 T 100 30 V50 H0 Z"/></svg>') repeat-x;
  background-size: 50% 100%;
  animation: sp-wave 4s linear infinite;
  bottom: 0;
}
@keyframes sp-wave {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ---------- Mobile overrides ------------------------------ */
@media (max-width: 767.98px) {
  .sp-main { padding: 1rem .75rem 2rem; }

  .sp-card { padding: 1rem; }

  .sp-stats-grid { gap: .5rem; }
  .sp-stat { padding: .75rem .5rem; }
  .sp-stat-value { font-size: 1.15rem; }
  .sp-stat-label { font-size: .7rem; }

  .sp-bid-bar {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .sp-search input { max-width: 100%; }

  /* Ensure touch targets are large enough */
  body.sp-backend .btn { min-height: 44px; }
  .sp-nav li a { padding: .85rem 1.25rem; }
}

/* ---------- Pulse animation for lead price column --------- */
@keyframes sp-pulse-font {
  0%, 100% { color: #0094b9; }
  50% { color: #de9e00; }
}
.sp-pulse-font {
  animation: sp-pulse-font 7s infinite;
}

/* ---------- Transcript (lead page) ------------------------ */
.sp-transcript { line-height: 1.6; }
.sp-transcript .turn.agent {
  background: #f0f8ff;
  padding: .35rem .5rem;
  border-left: 3px solid #007acc;
  margin-bottom: .35rem;
}
.sp-transcript .turn.user {
  background: #fff8f0;
  padding: .35rem .5rem;
  border-left: 3px solid #e67300;
  margin-bottom: .35rem;
}

/* ---------- Chat messages (lead page) --------------------- */
body.sp-backend .chat-message {
  background: #f1f1f1;
  padding: .5rem .75rem;
  border-radius: var(--sp-radius-sm);
  margin-bottom: .5rem;
  max-width: 80%;
  display: inline-block;
  font-size: .9rem;
}
body.sp-backend .chat-message.chat-message-assistant {
  text-align: left;
}
body.sp-backend .chat-message.chat-message-user {
  background: #0B9DF4;
  color: #fff;
  float: right;
  text-align: right;
}

/* ---------- Auto-refill form (payment page) --------------- */
.sp-refill-form .form-hint {
  font-size: .8rem;
  color: var(--sp-text-muted);
  margin-top: -.5rem;
  margin-bottom: .75rem;
}
.sp-refill-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .85rem;
}
.sp-refill-field {
  min-width: 0;
}
.sp-refill-label {
  font-size: .85rem;
  color: var(--sp-text);
  margin-bottom: .35rem;
  display: block;
  font-weight: 600;
}
.sp-refill-form .sp-refill-select {
  width: 100%;
}
.sp-custom-wrap {
  position: relative;
  margin-top: .45rem;
}
.sp-custom-currency {
  position: absolute;
  left: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--sp-text-muted);
  font-size: .85rem;
  pointer-events: none;
}
.sp-custom-input {
  width: 100%;
  padding: .55rem .75rem .55rem 1.45rem;
  border: 1px solid var(--sp-border);
  border-radius: var(--sp-radius-sm);
  font-size: .9rem;
  font-family: var(--sp-font);
  color: var(--sp-text);
  background: var(--sp-surface);
}
.sp-custom-input:focus {
  border-color: var(--sp-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(55,179,74,.12);
}

/* Backward compatibility if older markup is still present */
.sp-refill-form .inline-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  font-size: .9rem;
  font-weight: 500;
}
@media (max-width: 991.98px) {
  .sp-refill-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 767.98px) {
  .sp-refill-form .inline-group {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ---------- Prediction widget ----------------------------- */
.prediction-widget {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .875rem 1.1rem;
  border-radius: var(--sp-radius);
  border-left: 4px solid;
  font-size: .9rem;
  line-height: 1.45;
  margin-bottom: 1rem;
}
.prediction-widget.pw-success {
  background: var(--sp-primary-light);
  border-left-color: var(--sp-success);
}
.prediction-widget.pw-danger {
  background: #fef2f2;
  border-left-color: var(--sp-danger);
}
.prediction-widget.pw-neutral {
  background: #f0f4ff;
  border-left-color: var(--sp-info);
}
.pw-icon {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: .85rem;
}
.pw-success .pw-icon { background: var(--sp-success); color: #fff; }
.pw-danger  .pw-icon { background: var(--sp-danger);  color: #fff; }
.pw-neutral .pw-icon { background: var(--sp-info);    color: #fff; }
.pw-body {
  display: flex;
  flex-direction: column;
  gap: .15rem;
}
.pw-label {
  font-weight: 600;
  color: var(--sp-text);
}
.pw-hint {
  font-size: .82rem;
  color: var(--sp-text-muted);
}
.pw-hint a {
  color: var(--sp-primary);
  font-weight: 500;
  text-decoration: none;
}
.pw-hint a:hover { text-decoration: underline; }
