/* ==========================================================
   FILTER PANEL  — right-hand sidebar (third tab)
   ========================================================== */

#filter-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

/* ── Header ── */
.fp-header {
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.fp-section-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.fp-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  background: rgba(59,130,246,.18);
  border: 1px solid rgba(96,165,250,.32);
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 700;
}

.fp-section-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 1px;
}

.fp-section-copy strong {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}

.fp-section-copy span {
  color: rgba(255,255,255,.38);
  font-size: 9px;
  line-height: 1.35;
}

.fp-rules-heading { margin-bottom: 8px; }

.fp-logic-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fp-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.fp-toggle {
  display: flex;
  border: 1px solid var(--border-default);
  border-radius: 5px;
  overflow: hidden;
  flex-shrink: 0;
}

.fp-toggle-btn {
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 500;
  background: transparent;
  color: rgba(255,255,255,.4);
  border: none;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.fp-toggle-btn + .fp-toggle-btn {
  border-left: 1px solid var(--border-default);
}

.fp-toggle-btn.active {
  background: rgba(59,130,246,.3);
  color: var(--accent-light);
}

.fp-clear-btn {
  margin-left: auto;
  padding: 3px 8px;
  font-size: 10px;
  background: none;
  border: 1px solid var(--border-default);
  color: rgba(255,255,255,.3);
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
}
.fp-clear-btn:hover {
  border-color: var(--border-strong);
  color: rgba(255,255,255,.7);
}
.fp-clear-btn:disabled { opacity: .35; }

.fp-scope-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.fp-scope-badge {
  font-size: 10px;
  font-weight: 600;
  color: var(--accent-light);
  background: var(--accent-subtle);
  border: 1px solid rgba(96,165,250,.25);
  border-radius: 4px;
  padding: 1px 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* ── Spatial constraint (AOI) ── */
.fp-spatial {
  margin: 10px 10px 8px;
  padding: 10px;
  background: linear-gradient(145deg, rgba(59,130,246,.11), rgba(59,130,246,.035));
  border: 1px solid rgba(96,165,250,.24);
  border-radius: 9px;
  flex-shrink: 0;
}

.fp-spatial-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 9px;
}

.fp-sp-btn {
  justify-content: center;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border-default);
  color: rgba(255,255,255,.5);
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
}
.fp-sp-btn.fp-sp-primary {
  color: #dbeafe;
  background: rgba(59,130,246,.2);
  border-color: rgba(96,165,250,.45);
}
.fp-sp-btn:hover:not(:disabled) {
  background: rgba(255,255,255,.09);
  color: rgba(255,255,255,.8);
}
.fp-sp-btn.active {
  background: rgba(59,130,246,.25);
  border-color: var(--accent);
  color: var(--accent-light);
}
.fp-sp-clear:hover:not(:disabled) {
  background: rgba(220,60,50,.1);
  border-color: rgba(220,60,50,.3);
  color: #ff6b6b;
}
.fp-sp-btn:disabled { opacity: .3; cursor: not-allowed; }

.fp-sp-status {
  margin-top: 4px;
  font-size: 10px;
  color: rgba(255,255,255,.35);
}
.fp-sp-status.hidden { display: none; }
.fp-sp-status.fp-sp-ok    { color: #4ade80; }
.fp-sp-status.fp-sp-error { color: #ff6b6b; }

/* ── Dynamic export controls ── */
.fp-export-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.fp-export-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.fp-export-label {
  font-size: 10px;
  color: rgba(255,255,255,.35);
  white-space: nowrap;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fp-export-btn {
  flex-shrink: 0;
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border-default);
  color: rgba(255,255,255,.4);
  border-radius: 5px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.fp-export-btn:hover:not(:disabled) {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-light);
}
.fp-export-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Job results box ── */
.fp-jobs-box {
  flex-shrink: 0;
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.07) transparent;
}

.fp-job-card {
  padding: 7px 10px;
  border-top: 1px solid rgba(255,255,255,.04);
  font-size: 10px;
  color: rgba(255,255,255,.5);
  line-height: 1.6;
}
.fp-job-card strong { color: var(--text-primary); }

.fp-job-links {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}
.fp-job-dl {
  font-size: 10px;
  color: var(--accent-light);
  text-decoration: none;
}
.fp-job-dl:hover { text-decoration: underline; }
.fp-job-error { color: #ff6b6b; }

/* ── Rules list ── */
.fp-rules {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.07) transparent;
  min-height: 0;
}

.fp-rule-row {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  background: rgba(255,255,255,.01);
}
.fp-rule-row:hover { background: rgba(255,255,255,.025); }

.fp-rule-top {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 5px;
}

.fp-rule-bot {
  display: flex;
  align-items: center;
  gap: 4px;
}

.fp-rule-row select {
  width: auto !important;
  padding: 4px 18px 4px 6px !important;
  font-size: 11px !important;
  border-radius: 4px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23666' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 5px center !important;
  background-size: 7px !important;
}

.fp-metric-sel { flex: 1; min-width: 68px; }
.fp-period-sel { width: 66px; flex-shrink: 0; }
.fp-month-sel  { width: 44px; flex-shrink: 0; }
.fp-op-sel     { width: 44px; flex-shrink: 0; }

.fp-val {
  flex: 1;
  min-width: 52px;
  padding: 4px 6px;
  font-size: 11px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  height: auto !important;
  -webkit-appearance: auto;
  appearance: auto;
  margin: 0 !important;
  width: auto !important;
}
.fp-val:focus { outline: none; border-color: var(--accent); }

.fp-val-single { flex: 0 1 88px; min-width: 52px; }

.fp-between-sep {
  flex-shrink: 0;
  font-size: 11px;
  color: rgba(255,255,255,.3);
}

.fp-remove-btn {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.09);
  background: none;
  color: rgba(255,255,255,.3);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.fp-remove-btn:hover {
  background: rgba(220,60,50,.12);
  border-color: rgba(220,60,50,.35);
  color: #ff6b6b;
}

.fp-rule-hint {
  margin-top: 3px;
  min-height: 13px;
  font-size: 10px;
  color: rgba(255,255,255,.25);
}

/* ── Add rule row ── */
.fp-add-row {
  padding: 6px 10px;
  border-top: 1px solid rgba(255,255,255,.04);
  flex-shrink: 0;
}

.fp-add-btn {
  width: 100%;
  padding: 5px;
  background: none;
  border: 1px dashed rgba(255,255,255,.11);
  border-radius: 5px;
  color: rgba(255,255,255,.3);
  font-size: 11px;
  cursor: pointer;
  transition: all .15s;
}
.fp-add-btn:hover:not(:disabled) {
  border-color: rgba(96,165,250,.38);
  color: var(--accent-light);
  background: var(--accent-subtle);
}
.fp-add-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Footer ── */
.fp-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-base);
  padding: 8px 10px;
}

.fp-apply-btn {
  width: 100%;
  padding: 8px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: .15s;
  margin-bottom: 6px;
}
.fp-apply-btn:hover:not(:disabled) { background: var(--accent-hover); }
.fp-apply-btn:active:not(:disabled) { transform: scale(.98); }
.fp-apply-btn:disabled { opacity: .35; cursor: not-allowed; }

.fp-cells-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 6px;
}

.fp-result {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  min-height: 16px;
}

.fp-match-count {
  color: var(--accent-light);
  font-weight: 600;
}

.fp-mask-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 7px;
  border-top: 1px solid rgba(255,255,255,.05);
  flex-wrap: wrap;
}

#fp-mask-toggle .fp-toggle-btn {
  padding: 2px 6px;
  font-size: 10px;
}

.fp-mask-hint {
  font-size: 10px;
  color: rgba(255,255,255,.2);
  margin-left: auto;
}
