/* Overlay */
.sqfs-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 99999;
  display: none;            /* toggled via .is-open */
  align-items: center;
  justify-content: center;
  padding: 4vh 16px;
}

.sqfs-modal.is-open { display: flex; }

/* Dialog */
.sqfs-dialog {
  background: #fff;
  width: min(1080px, 96vw);
  border-radius: 14px;
  box-shadow: 0 20px 45px rgba(2, 6, 23, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 92vh;
  border: 1px solid #e5e7eb;
}

/* Header */
.sqfs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #f1f5f9;
  background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.sqfs-header h3 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
}

.sqfs-close {
  border: 0;
  background: transparent;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  padding: 0 10px;
  margin-top: -10px;
}
.sqfs-close:hover { color: white; }

/* Form */
.sqfs-form { margin-bottom: 10px; }

.sqfs-field-group {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 16px;
}

@media (max-width: 880px) {
  .sqfs-field-group { grid-template-columns: 1fr; }
}

.sqfs-field label {
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}

.sqfs-distance {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.sqfs-distance input { width: 140px; }
.sqfs-units { font-weight: 600; color: #0f172a; }
.sqfs-help { color: #64748b; font-size: 12px; display: block; margin-top: 6px; }


.sqfs-actions { margin-top: 8px; }

.sqfs-loading,
.sqfs-error,
.sqfs-empty {
  padding: 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
}

/* Footer */
.sqfs-footer {
  border-top: 1px solid #f1f5f9;
  padding: 12px 16px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  bottom: 0;
}
.sqfs-selection-count { color: #334155; font-size: 13px; }
#sqfs-name { width: 100%; max-width: 460px; }

/* Body becomes a two-column grid */
.sqfs-body {
  padding: 18px;
  /* prevent the whole body from scrolling; let columns manage scroll */
  overflow: hidden;
}

.sqfs-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;  /* 50/50 split */
  gap: 18px;
}

@media (max-width: 980px) {
  .sqfs-two-col { grid-template-columns: 1fr; }
}

/* Ensure columns can host their own scrollers */
.sqfs-col-left,
.sqfs-col-right {
  min-height: 0; /* required so overflow works inside CSS grid */
}

/* Category list WITH its own scroll (bring back scroller) */
.sqfs-cats {
  max-height: min(50vh, 420px);
  overflow: auto;
  border: 1px solid #e2e8f0;
  padding: 10px;
  border-radius: 10px;
  background: #fff;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  column-gap: 18px;
  row-gap: 6px;
}
@media (max-width: 1280px) {
  .sqfs-cats { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}
@media (max-width: 640px) {
  .sqfs-cats { grid-template-columns: 1fr; }
}

.sqfs-cat {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
}

/* Results column should scroll independently */
.sqfs-col-right {
  overflow: auto; /* live results scroll */
  border-left: 1px dashed #eef2f7;
  padding-left: 12px;
  width: 100%;
}
@media (max-width: 980px) {
  .sqfs-col-right { border-left: 0; padding-left: 0; }
}

/* Results list visuals (unchanged, included for completeness) */
.sqfs-results { min-height: 84px; }
.sqfs-list { display: grid; gap: 10px; }
.sqfs-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
}
.sqfs-item:hover { border-color: #cbd5e1; }
.sqfs-item-name { font-weight: 700; margin-bottom: 6px; color: #0f172a; }
.sqfs-item-meta { font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap; color: #475569; }
.sqfs-badge { display:inline-block; font-size:11px; line-height:1; padding:6px 8px; border-radius:999px; border:1px solid #e2e8f0; background:#f8fafc; margin: 0;}

.fav-card .sqfs-badge {margin: 3px 5px 0 0;}


.sqfs-footer-left {
  margin-left: 10px;
}
.sqfs-footer-right {
  margin-right: 0;
}

#sqfs-add-selected {
  padding: 6px 14px;
}






























/* Make each item 3-column: checkbox | main | toggle */
.sqfs-item {
  grid-template-columns: 22px 1fr auto;  /* was 22px 1fr */
  align-items: start;
}

/* Name row + favorite badge */
.sqfs-item-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.sqfs-item-name {
  font-weight: 700;
  color: #0f172a;
}

/* Favorite badge styling */
.sqfs-badge-fav {
  background: #fef3c7;           /* amber-100 */
  border-color: #fde68a;         /* amber-200 */
  color: #92400e;                /* amber-800 */
}

/* Toggle button */
.sqfs-toggle {
  align-self: start;
  margin-top: 6px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  line-height: 1;
}
.sqfs-toggle.is-open { transform: rotate(180deg); }

/* Details panel */
.sqfs-item-details {
  grid-column: 2 / 3;         /* align under main column */
  margin-top: 8px;
}
.sqfs-cats-exp {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 2px;
}
.sqfs-empty-note { color: #64748b; }





/* Base item grid: checkbox | content | toggle */
.sqfs-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #ffffff;
  width: 100%;
}
.sqfs-item:hover { border-color: #cbd5e1; }

/* Main column stacks name/top row and meta row cleanly */
.sqfs-item-main {
  display: grid;
  grid-template-rows: auto auto;
  gap: 6px;
}

/* Top row: name + favorite badge */
.sqfs-item-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 22px;
}
.sqfs-item-name {
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
}

/* Meta badges row */
.sqfs-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: #475569;
}

/* Capsule style */
.sqfs-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  line-height: 1;
  max-width: 100%;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Already favorite */
.sqfs-badge-fav {
  background: #fef3c7;           /* amber-100 */
  border-color: #fde68a;         /* amber-200 */
  color: #92400e;                /* amber-800 */
}

/* Toggle button (chevron) */
.sqfs-toggle {
  align-self: start;
  margin-top: 4px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 8px;
  padding: 2px 8px 4px;
  cursor: pointer;
  line-height: 1;
  transition: transform .15s ease;
}
.sqfs-toggle.is-open { transform: rotate(180deg); }

/* Details panel under content column with divider */
.sqfs-item-details {
  grid-column: 2 / 3;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
}
.sqfs-cats-exp {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sqfs-empty-note { color: #64748b; }


/* Company suggestions dropdown */
.sqfs-suggest {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% - 30px);
  z-index: 100000;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.15);
  margin: 0;
  padding: 6px 0;
  list-style: none;
  max-height: 240px;
  overflow: auto;
  display: none;
}

.sqfs-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.sqfs-suggest-item:hover,
.sqfs-suggest-item.is-active {
  background: #f8fafc;
}

.sqfs-suggest-name {
  font-weight: 600;
  color: #0f172a;
  margin-left: 0;
  font-size: 15px;
}

.sqfs-suggest-meta {
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
  margin-right: 0;
}




